By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,557 Members | 1,184 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,557 IT Pros & Developers. It's quick & easy.

Save routine not working

P: 4
Hi Everybody,

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

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
  1. Me.objDataAdapter = New OleDbDataAdapter("Select * from datatable", Me.objConnection)
  3.         Me.objDataAdapter.Fill(Me.objDataTable)
  5.         Me.BindingSource1.DataSource = Me.objDataTable
  6.         Me.BindingNavigator1.BindingSource = Me.BindingSource1
  7.         Me.BindingNavigator1.Dock = DockStyle.None
  8.         Me.Controls.Add(Me.BindingNavigator1)
  10.         Me.Controls.Add(Me.RichTextBox1)
  11.         Me.RichTextBox1.DataBindings.Add(New Binding("Text", Me.BindingSource1, "audit_task_no", True)) 

The following is the save routine.

Expand|Select|Wrap|Line Numbers
  1.         Try
  2.             Me.objDataAdapter.Update(Me.objDataTable)
  3.             MsgBox("Changes Successful Saved ")
  4.         Catch ex As Exception
  5.             MsgBox("Saved Failed")
  6.         End Try
  8.         Try
  9.             Me.objDataTable.AcceptChanges()
  10.         Catch ex As Exception
  11.             MsgBox("Update failed")
  12.         End Try 
I have declared objDataAdapter and other variables gloable thats why I am using Me.objDataAdapter.
Nov 25 '06 #1
Share this Question
Share on Google+
1 Reply

P: 4
What do I mean when I say that I am not able to save the changes?
I mean that they are not reflected in the database when I reopen it.

Does an error occur?
No error occurs.

If not then how am I determining that the save operation didn't work?
No changes are reflected in the database.

What value does Update return?
It returns zero.

So, there might be a problem with the update function.

I am binding the richtext box with the bindingsource. And the bindingsource is the datatable. Are the values in the datatable automatically updates when I change a value in the richtext box? If not how can I do that.

Any kind of suggestion would be highly appreciated.
Thanking you in anticipation.
Nov 26 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.