Friend Sub Inventory_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'Connect to database
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source= C:/Inventory.mdb"
con.ConnectionString = dbProvider & dbSource
'Open database connection
con.Open()
MsgBox("Inventory is opened now")
'Import the data on tables
sql = "SELECT * FROM Brands"
sql1 = "SELECT * FROM Model"
da = New OleDb.OleDbDataAdapter(sql, con)
da1 = New OleDb.OleDbDataAdapter(sql1, con)
'Build up database Adapters
da.Fill(ds, "Inventory")
da1.Fill(ds, "Inventory2")
maxrows = ds.Tables("Inventory").Rows.Count
maxrows1 = ds.Tables("Inventory2").Rows.Count
inc = -1
inc1 = 0
con.Close()
'Calling the list of tire's brands
For i As Integer = 0 To ds.Tables("Inventory").Rows.Count - 1
Me.BrandsComboBox.Items.Add(ds.Tables("Inventory").Rows(i).Item(0))
Next i
End Sub
Friend Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click
Dim ch As New OleDb.OleDbCommandBuilder(da1)
Dim i As Integer
For i = 0 To ds.Tables("Inventory2").Rows.Count - 1
If ds.Tables("Inventory2").Rows(i).Item(1) = ModelsComboBox.Text Then
ds.Tables("Inventory2").Rows(i).Item(2) = PriceTextBox.Text
ds.Tables("Inventory2").Rows(i).Item(3) = InStockTextBox.Text
End If
Next i
** da1.Update(ds, "Inventory2")** I got an error with this sentence
End Sub
an error said that
OLEDB.Exception was unhandled
Syntax error in UPDATE statement.
I have changed from Inventory2 to Model which is the column name in the database
but it updated to dataset, not to my database. any suggestion?