PDA

View Full Version : VB.NET Data editting


jamescull
09-15-2003, 05:38 PM
I was wondering if anyone might have an answer to my question...

I bought a book to learn VB.NET and it goes through adding, editing and deleting records. My problem is that their solution for editing and deleting don't seem to work.

Editing
=====
SqlDataAdapter1.Update(DataSet1)
DataSet1.AcceptChanges()

Deleting
======
Dim pos As Integer = Me.BindingContext(DataSet1, "Table").Position
Dim row as DataRow = DataSet1.Table.Rows(pos)
DataSet1.Table.RemoveTableRow(row)
Me.BindingContext(DataSet1, "Table").Position -= 1

When I add records and push the button associated with the "Editing" code a new record is added. When I try to edit a record and push the same button the changes are not saved back to the database. Likewise, when I delete a record and push the save button the records are not removed.

Any ideas?

Thanks in advance,
James