Sin Jeong-hun,
I think you really should look into the TransactionScope class in the
System.Transactions namespace. It will allow you to create a scope of code
where there is a transaction, and you can call Commit at the end of the code
to commit all the changes. If you don't, then everything is automatically
rolled back.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
(E-Mail Removed)
"Sin Jeong-hun" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi.
> I wrote a C# program that uses System.Data.OleDb (MS Access). For a
> certain operation, it calls bunch of ExecuteScalar(). The problem is,
> if any of those ExecuteScalar failes, then the whole DB becomes
> unstable data. So can I set a rollback point or group them in a one
> transaction?
> Some pseudo-code like,
> try
> {
> MyCommand.SetRollbackPoint();
> MyCommand.ExecuteScalar();
> MyCommand.ExecuteScalar();
> .....
> MyCommand.ExecuteScalar();
> }
> catch
> {
> MyCommand.Rollback();
> }
>
> -------OR----------
> MyCommand.StartTransaction();
> MyCommand.ExecuteScalar();
> MyCommand.ExecuteScalar();
> .....
> MyCommand.ExecuteScalar();
> MyCommand.EndTransaction();
>
> Any suggestions will be welcome! Thank you.
>