Using dataset after insert, update, or delete

  • Thread starter Thread starter Jim P.
  • Start date Start date
J

Jim P.

I'm trying to refresh a datagrid after I insert, update, or delete rows from
a DataSet. Once the database has been altered, do I need to re-query the
database?? Or is the DataSet reflective of the current state of the
database?

thanks
 
No it is not reflective, Once U read that transactions are
sucessfull U need to call the Acceptchanges to update the
status of the DataTable.

Regards
Mahesh
 
It depends on how do you handle concurrent conflicts ( if it could happen ).

If there is no other user changes data during your app session, after you
update data from your dataset back to database through DataAdapter, ( no
concurrent conflicts occur ), then, of course, the DataSet reflects the
database's status at the monemt of updating, and by default, you do not need
to call DataSet.AcceptChanges() explicit, 'cause DataAdapter calls it by
default.

If there is possibility of concurrent confilict, but you implement
concurrenct conflicts rules onter than "Last Wins", then the DataSet, after
updating to database, may no reflect database's status. For example, you
changed a row in a table, and when updating to DB, a concurrency error
occurs, indicating that row has be changed by other user, so the row in db
is not updated by your change, but it has changed by other uer. Whether you
accept or reject your change in your DataSet, the row will be different from
the row in database now.
 
Back
Top