Versaiteis
Member
- Joined
- Mar 12, 2010
- Messages
- 14
- Programming Experience
- 1-3
Alright, I admit that I have a similar post in the MS Access section, but I feel that the problem that I am having relies between the data adapter and the command builder =\
da=data adapter
ds=dataset
The Insert command that the message box displays looks fine, I can see no syntax errors in it, and yet the program crashes on the update line
I will be more than happy to provide any other needed information, I am quite at a loss for what to do next. This problem has been a thorn in my side for a while -_-
da=data adapter
ds=dataset
VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "PROVIDER=Microsoft.ACE.OLEDB.12.0;Data Source = Single.mdb"
con.Open()
sql = "SELECT * FROM tblClients"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "AddressBook")
con.Close()
Private Sub btnCommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCommit.Click
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
MsgBox(cb.GetInsertCommand.CommandText)
da.InsertCommand = cb.GetInsertCommand
da.UpdateCommand = cb.GetUpdateCommand
da.DeleteCommand = cb.GetDeleteCommand
dsNewRow = ds.Tables("AddressBook").NewRow()
dsNewRow.Item(0) = 3
dsNewRow.Item(1) = txtFirstName.Text
dsNewRow.Item(2) = Date.Now
ds.Tables("AddressBook").Rows.Add(dsNewRow)
da.Update(ds, "AddressBook")
MsgBox("New Record added to Database")
btnCommit.Enabled = False
btnAddNew.Enabled = True
btnUpdate.Enabled = True
btnDelete.Enabled = True
End If
End Sub
The Insert command that the message box displays looks fine, I can see no syntax errors in it, and yet the program crashes on the update line
VB.NET:
da.update(ds, "AddressBook")
I will be more than happy to provide any other needed information, I am quite at a loss for what to do next. This problem has been a thorn in my side for a while -_-