I am trying to update a single table in an Access database. Heres my code:
Dim strSql As String = "SELECT * FROM ProductDB"
Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter
Dim builder As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(da)
Dim dr as DataRow
da.SelectCommand = New OleDb.OleDbCommand(strSql)
da.SelectCommand.Connection = conn
da.UpdateCommand = builder.GetUpdateCommand
da.InsertCommand = builder.GetInsertCommand
da.DeleteCommand = builder.GetDeleteCommand
dr = dt.NewRow
' dr.BeginEdit() 'Superfluous
dr.Item(0) = txtName.Text
dr.Item(1) = txtBrand.Text
dr.Item(2) = txtWeight.Text
dr.Item(3) = txtColor.Text
dr.Item(4) = txtPrice.Text
' dr.EndEdit() ' Superfluous
dt.rows.add(dr)
If MessageBox.Show("Add", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.OK Then
dt.AcceptChanges()
Else
dt.RejectChanges()
End If
MessageBox.Show(da.Update(dt).ToString)
Anyway, my guess is that I'm not using the commandbuilder properly. Any guidance or suggestions would help a lot. Also is there a select command builder

Why doesn't dataadapter.update(datatable) work?
Hippunky
seadur
So the only way to reject changes was to call the rejectchanges() before using da.update()
Edit:
didn't realize there was a AcceptChangesDuringUpdate property which on default is set to true. So it was indeed automatically calling the acceptchanges()
CHOULANT Noham
kmoreto