Why isn't my database getting updated?

  • Thread starter Thread starter Rob Richardson
  • Start date Start date
R

Rob Richardson

I am sure there is something elementary I am leaving out, and by this
question I am revealing myself as the newbie I am.

I have a typed dataset that contains a table named "Orders". When a user
enters a new order, I create an OrdersRow object, then I call my table's Add
method, passing in the new row object, and finally I call my table's
AcceptChange method. No exceptions get thrown, but the new row does not
appear in the database.

Thanks very much!

Rob
 
Hi Rob,

Do you have insert commands or a commandbuilder object? Do you call the
data adapters update method?

Bernie Yaeger
 
Like Bernie mentions, until you call the update method of your dataadapter,
nothing is going to be sent back to the db. All Acceptchanges does is
change the rowstate of the rows so they aren't flagged as
modified/deleted/inserted etc and if you call acceptchanges first , your
update is never going to get back to the db.
 
Rob,

By calling the AcceptChanges() method, you are effectively setting the row state to "Unmodified". You must persist it back to the database prior to this call, so it is seen as "Added" to the DataTable. Use the DataAdapter.Update() method and supply the Insert, Update, and Delete Commands as appropriate in your situation.

HTH,

Jeff
 
Back
Top