I am writing an application using the bindingnavigator and the oledbDataAdapter. I am not able to save the changes to the actual access database. Please help me. The code follows.
Thank you
Vishal
I have opened a connection and the following code binds the database with the bindingnavigator using a oledbDataAdapter. And also to the text box. Where we can edit the fields and later on save them.
Expand|Select|Wrap|Line Numbers
- Me.objDataAdapter = New OleDbDataAdapter("Select * from datatable", Me.objConnection)
- Me.objDataAdapter.Fill(Me.objDataTable)
- Me.BindingSource1.DataSource = Me.objDataTable
- Me.BindingNavigator1.BindingSource = Me.BindingSource1
- Me.BindingNavigator1.Dock = DockStyle.None
- Me.Controls.Add(Me.BindingNavigator1)
- Me.Controls.Add(Me.RichTextBox1)
- Me.RichTextBox1.DataBindings.Add(New Binding("Text", Me.BindingSource1, "audit_task_no", True))
The following is the save routine.
Expand|Select|Wrap|Line Numbers
- Try
- Me.objDataAdapter.Update(Me.objDataTable)
- MsgBox("Changes Successful Saved ")
- Catch ex As Exception
- MsgBox("Saved Failed")
- End Try
- Try
- Me.objDataTable.AcceptChanges()
- Catch ex As Exception
- MsgBox("Update failed")
- End Try