I'm having problems in updating records from excel using VB 2010
where its Header is at Row 5 in Excel.
The Update part is fine what I'm having trouble is where it updates.
Scenario: I want to update a record whose IDVal is at Row 5 in Datagridview but instead
the value I put in row 5 was placed in Row 1 in Datagridview.
Here's my code:
Dim MyConnection As New OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0; Data Source='" & path & "'; Extended Properties=Excel 12.0;")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM [Sheet1$A5:R1048576] where [ITEM CODE] is not null", MyConnection)
adpt = New OleDbDataAdapter(cmd)
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(adpt)
DtSet = New DataSet()
DataGridView1.DataSource = DtSet.Tables(0).DefaultView
Dim updt As OleDbCommand = New OleDbCommand("Update [Sheet1$A5:R1048576] Set [Inventory on Hand] = '" & Label4.Text & "' where [ITEM CODE] = '" & Label5.Text & "'", MyConnection)