DataAdapter.Update works w/ datagrid but not w/ textboxes

J

johnb41

I have a very simple application where i just want to display records
from a database, and be able to edit the records.

Here's the code for the "update" button:

Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnUpdate.Click
DA.Update(DataSet, "mytable")
End Sub

If I display the records in a DATAGRID, and edit a record and then
click my Update button, it updates perfectly.

However, if i bind the data to a series of textboxes, the Update button
does not work.

I actually made a form that included both a datagrid and textboxes
(displaying the same data). For some reason, the Update would just not
work when edited from a textbox.

Note: the DataAdapter and connection were created using the IDE, so i
didn't need to create a commandbuilder. The updatecommand.commandtext
was created automatically when i created the DataAdapter.

Any help w/ this problem will be greatly appreciated!

Thanks!
John
 
K

Kevin Hodgson

Make sure in your update button event, that you End the current edit.
Add
BindingContext(DataSet.Tables(0)).EndCurrentEdit()
Before you do the DataAdapter.Update
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top