DataAdapter Update

J

J L

If a DataAdapter.Update fails mid-way through the dataset, are earlier
updates rolled back or how is this handled?

For example, let's say I am a dummy and I create a dataset without
setting a unique key constraint. Then I try to do an update on the
underlying database. It would fail on the records with duplicates in
the unique key field. What is the state of my database at that time? I

Hope that question makes sense.

TIA
John
 
G

Guest

Hello JL,

As Cor said, there are multiple answers to this question.

I noticed you posted on one of my topics and you mentioned, I am too
building a Data Access Layer and I am coming up with this types of questions
myself.

As a matter of fact, I posted "Updating DataSets 2nd Part" because of the
very same issue you are asking about. What I am trying to do in my DAL is
returning the same DataSet I receive to update, but marking the DataRows
which did not successfully updated back to the DataSource.

For instance, in your example, my DAL would return the same dataset, but the
record missing the field would have a message on the filed RowError and the
flag HasError would return true.

Take a look at
http://msdn.microsoft.com/library/d...oledboledbdataadapterclassrowupdatedtopic.asp

specially at the RowUpdated event handling.

This is just one way of dealing with this situations. Hope this helps.
:)
 
J

J L

Thank you Cor and Abelardo,
I think using a connection transaction is my best approach.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top