|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Transactions under ADO.NET 1.1I have a relatively simple question. I am doing a batch process which consits of reading a table then maybe writing and updating etc. The whole process works like this: Open SqlConnection Create a SqlTransaction object and call BeginTransaction on the SqlConnection object Write to a table Read a table uisng DataAdapter -- Does not allow me to do this. Update a table Close SqlConnection. If the above process complets then I want to Commit the transaction, if it fails then I want to Rollback the changes. The above process is fairly hairy and the writing and updating is based on various reads. But ADO.NET does not seem to allow me to read a table after calling BeginTransaction on the SqlConnection object? I am using OleDb provider because I am doing the above on a Microsoft Access 2000 database. Any ideas on how to get around this will be great. Of course I could split it up but this will be hard to code as I need to read tables in the middle of the transaction. Regards Simon. It's OK, I have having I think as s*it day. Simply using the
DataAdpater.SelectCommand, UpdateCommand or DeleteCommand's Transaction property achives the desired result. Simon. Show quote "Simon Hart" <srhartone@[no spam]yahoo.com> wrote in message news:%238Ysm6bTGHA.4952@TK2MSFTNGP09.phx.gbl... > Hi, > > I have a relatively simple question. I am doing a batch process which > consits of reading a table then maybe writing and updating etc. The whole > process works like this: > > Open SqlConnection > Create a SqlTransaction object and call BeginTransaction on the > SqlConnection object > Write to a table > Read a table uisng DataAdapter -- Does not allow me to do this. > Update a table > Close SqlConnection. > > If the above process complets then I want to Commit the transaction, if it > fails then I want to Rollback the changes. > The above process is fairly hairy and the writing and updating is based on > various reads. But ADO.NET does not seem to allow me to read a table after > calling BeginTransaction on the SqlConnection object? > > I am using OleDb provider because I am doing the above on a Microsoft > Access 2000 database. > > Any ideas on how to get around this will be great. Of course I could split > it up but this will be hard to code as I need to read tables in the middle > of the transaction. > > Regards > Simon. > > > > > |
|||||||||||||||||||||||