Updating access through VB

  • Thread starter Thread starter karthik.charan
  • Start date Start date
K

karthik.charan

Hi

I am a new to VB.net, I am using access as my database

I am trying to show some tables in Vb using Datagrids, I am able to add
rows to the table and update those changes to the access file, but when
i try to delete rows its not being updated to the database,

Any help will be appreciated,

The code for the button click event is as follows:

Dim a As Integer
a = DataSet11.tietransverseempty.Count
OleDbDataAdapter2.Update(DataSet11, "tietransverseempty")
While (a > TextBox18.Text)

DataSet11.tietransverseempty.Rows(a - 1).Delete()
DataSet11.tietransverseempty.AcceptChanges()
a = DataSet11.tietransverseempty.Count
End While
 
They never will. You call Delete and then immediately afterward call
AcceptChanges. That resets rowstate so nothing will ever update at that
point. The Update method calls AcceptChanges row by row as it updates, so
take out the AcceptChanges and put the update at the end of the loop (or at
it). That should fix your problem, ifnot let me know.
 
Hi there

I actually tried that earlier, when i put the acceptchanges statement
after the loop the program just hangs up.

When I put it within the program as in the code above, the datagrid
gets updated (that is the rows are deleted and added ) but I am having
difficult updating the changes to the access file, i mean adding part
works fine but when i delete rows, it is only reflected in the datagrid
and not in the actual database.

Help will be appreciated

Thanks in advance
 
Adding to what I have written today, when i put the acceptchanges
after the loop it is going into this infinite loop, because the value
of a is remaining unchanged, a = the number of rows.

Thanks

Help needed
 
Back
Top