Datagrid doesn't update

  • Thread starter Thread starter Wanda
  • Start date Start date
W

Wanda

I am using vb.net and have a bounded datagrid by using SQLDataAdaptor
and SQLDataSet, it does show the data when it is first loaded. But
when I change the data on the datagrid, it doesn't update the
database, even I use AcceptChanges...

What am I missing? What I am expecting is it should update the
database automatically without doing it manually with the code.

Please help!!!!

Thanks in advance.
Wanda
 
Are you sure your dataset .HasChanges before calling update? IF not, calling
update all year won't do anything. And DO NOT CALL acceptchanges before the
update. This will essentially return the rowstates of everything back to
Unchanged and it will physically delete rows marked as Deleted. If you call
AcceptChanges before Update, your DB will never be updated.

ALso, are you getting an exception on update? Make sure it's not wrapped in
try catch with no action being taken...that can mask errors.

If HasChanges is true, your update command is valid you should be able to
update. If no exceptions are thrown, you have a weird problem indeed, but I
don't think it's that.

Let me know.
 
I've an Update button on my screen...when the button is clicked the
following code will be executed...So, I have no idea what I am missing.
Is there any setting I have to apply to the dataset or the datagrid in
order to update the changes?

If custDS.HasChanges Then
custDS.AcceptChanges()
End If

Please suggest. Thanks in advance.

Wanda
 
AcceptChanges does not send an update to the db Don't ever call this before
DataAdapter.Update(dataset) or it Will NEVER be updated. This changes the
rowstates of the added/delted/modified rows back to unchanged(well, it
actually deletes the deleted rows).

Call DataAdapter.Update(dataSet, datatable) instead
 
Back
Top