467,880 Members | 1,087 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,880 developers. It's quick & easy.

Save routine not working

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

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
  7.  
  8.         Try
  9.             Me.objDataTable.AcceptChanges()
  10.         Catch ex As Exception
  11.             MsgBox("Update failed")
  12.         End Try 
  13.  
I have declared objDataAdapter and other variables gloable thats why I am using Me.objDataAdapter.
Nov 25 '06 #1
  • viewed: 1324
Share:
1 Reply
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.
vishal
Nov 26 '06 #2

Post your reply

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

Similar topics

8 posts views Thread by Pavan Arise | last post: by
4 posts views Thread by Andras Gilicz | last post: by
10 posts views Thread by GJP | last post: by
1 post views Thread by =?Utf-8?B?U2hhdw==?= | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.