I am attempting to use native Vantage customization to access the business
objects for the Part table (I do not have Service Connect or Visual Studio).
My goal is to update our part selling prices in Vantage based upon input
from an excel spreadsheet. I am using the UD10 form as a platform and have
added a sheet with a button on it to initiate the code. I can update the
price on a single part successfully but I am having trouble when trying to
update multiple part records. The code reads through the excel spreadsheet
OK, however, it only manages to update the Part table record for the first
part number listed in the spreadsheet. That first Part record is on the
receiving end of all the price updates contained in the spreadsheet.
Somehow, I am not retrieving new Part records on subsequent iterations of my
read loop. Please see code below. Any and all input is greatly appreciated.
Thank you!
Peter Dunbar
Halm Industries Co., Inc.
Private Sub btnEpiCustom1_Click(ByVal Sender As Object, ByVal Args As
System.EventArgs) Handles btnEpiCustom1.Click
'// ** Place Event Handling Code Here **
'newPrice = 79.75
'ds = New DataSet()
partAdapter = New partAdapter(UD10Form)
partAdapter.BOConnect()
'partDataView = New EpiDataView()
'partDataView.dataview = New DataView(partAdapter.PartData.Part)
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\NewUnitPrice.xls;Extended Properties=""Excel
8.0;HDR=YES;""")
cn.Open()
cmd = New OleDbCommand("Select * from [Sheet1$]")
cmd.Connection = cn
rdr = cmd.ExecuteReader
Do While rdr.Read()
strPartNum = Trim(rdr("partnum"))
strUnitPrice = rdr("unitprice")
'Dim found As Boolean = partAdapter.GetByID(strPartNum)
'MessageBox.Show("PartNum: " & strPartNum & ",UnitPrice: " &
strUnitPrice)
'If (found) then
If partAdapter.GetByID(strPartNum)then
'Call MsgBox("part number found!")
partAdapter.PartData.Tables("Part").Rows(0).BeginEdit()
partAdapter.PartData.Tables("Part").Rows(0)("UnitPrice")=
strUnitPrice
partAdapter.PartData.Tables("Part").Rows(0).EndEdit()
partAdapter.Update()
partCounter = partCounter + 1
End If
Loop
Call MsgBox("Number of Parts Updated: " & Trim(partCounter))
rdr.Close()
cn.Close
End Sub
objects for the Part table (I do not have Service Connect or Visual Studio).
My goal is to update our part selling prices in Vantage based upon input
from an excel spreadsheet. I am using the UD10 form as a platform and have
added a sheet with a button on it to initiate the code. I can update the
price on a single part successfully but I am having trouble when trying to
update multiple part records. The code reads through the excel spreadsheet
OK, however, it only manages to update the Part table record for the first
part number listed in the spreadsheet. That first Part record is on the
receiving end of all the price updates contained in the spreadsheet.
Somehow, I am not retrieving new Part records on subsequent iterations of my
read loop. Please see code below. Any and all input is greatly appreciated.
Thank you!
Peter Dunbar
Halm Industries Co., Inc.
Private Sub btnEpiCustom1_Click(ByVal Sender As Object, ByVal Args As
System.EventArgs) Handles btnEpiCustom1.Click
'// ** Place Event Handling Code Here **
'newPrice = 79.75
'ds = New DataSet()
partAdapter = New partAdapter(UD10Form)
partAdapter.BOConnect()
'partDataView = New EpiDataView()
'partDataView.dataview = New DataView(partAdapter.PartData.Part)
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\NewUnitPrice.xls;Extended Properties=""Excel
8.0;HDR=YES;""")
cn.Open()
cmd = New OleDbCommand("Select * from [Sheet1$]")
cmd.Connection = cn
rdr = cmd.ExecuteReader
Do While rdr.Read()
strPartNum = Trim(rdr("partnum"))
strUnitPrice = rdr("unitprice")
'Dim found As Boolean = partAdapter.GetByID(strPartNum)
'MessageBox.Show("PartNum: " & strPartNum & ",UnitPrice: " &
strUnitPrice)
'If (found) then
If partAdapter.GetByID(strPartNum)then
'Call MsgBox("part number found!")
partAdapter.PartData.Tables("Part").Rows(0).BeginEdit()
partAdapter.PartData.Tables("Part").Rows(0)("UnitPrice")=
strUnitPrice
partAdapter.PartData.Tables("Part").Rows(0).EndEdit()
partAdapter.Update()
partCounter = partCounter + 1
End If
Loop
Call MsgBox("Number of Parts Updated: " & Trim(partCounter))
rdr.Close()
cn.Close
End Sub