Check If Commit Works Correctly

  • Thread starter Thread starter jehugaleahsa
  • Start date Start date
J

jehugaleahsa

Is there a sane way to ensure that if a record is committed on the
database that it is committed in a DataTable?

Of course, this is using a DataAdapter that can ContinueOnUpdateError
and AcceptChangesDuringUpdate. And those two properties can be set in
any fashion.

Also remember that there may or may not be a database transaction. In
which case all commands to the database are auto-committed and so
should be in the DataTable.

With all these wacky, wild options, can the typical programmer handle
all possible cases within a single method?

Let me know,
Travis
 
Travis,

The documentation for the ContinueUpdateOnError property states that if
there is an error, then the RowError property of the row in the DataTable
will be set to the error that occured. You should be able to check for
this. Or, if an exception is thrown, you can assume that some of the
records were not updated (because you might not have been in a transaction).

If you are in a transaction, then you need to perform your check outside
of the transaction, since the whole thing can be rolled back. However, you
should know when this is, and if you are not able to commit the transaction,
you should assume that no records were comitted.
 
Travis,

The documentation for the ContinueUpdateOnError property states that if
there is an error, then the RowError property of the row in the DataTable
will be set to the error that occured. You should be able to check for
this. Or, if an exception is thrown, you can assume that some of the
records were not updated (because you might not have been in a transaction).

If you are in a transaction, then you need to perform your check outside
of the transaction, since the whole thing can be rolled back. However, you
should know when this is, and if you are not able to commit the transaction,
you should assume that no records were comitted.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Is there a sane way to ensure that if a record is committed on the
database that it is committed in a DataTable?
Of course, this is using a DataAdapter that can ContinueOnUpdateError
and AcceptChangesDuringUpdate. And those two properties can be set in
any fashion.
Also remember that there may or may not be a database transaction. In
which case all commands to the database are auto-committed and so
should be in the DataTable.
With all these wacky, wild options, can the typical programmer handle
all possible cases within a single method?
Let me know,
Travis- Hide quoted text -

- Show quoted text -

I was hoping that the RowError was set. However, I couldn't find any
proof of that. Thank you for your response; I will see what I can do!

Thanks,
Travis
 

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

Back
Top