transactionscope

TransactionScope error in ambient transaction does not rollback the transaction

会有一股神秘感。 提交于 2019-12-02 09:08:19
问题 I use an ambient transaction like this : using(TransactionScope tran = new TransactionScope()) { CallAMethod1();//INSERT CallAMethod2();//INSERT tran.Complete(); } The method CallAMethod2(); returns affected rows =-264 So it fails to insert however the first Insert has been committed ! I want to know how to work with ambient transaction and what if the second method has more than one action which needs internal transaction , should i put these actions in internal transaction ? like this : DAL

Child Parent Transactions roll back

徘徊边缘 提交于 2019-12-02 08:57:50
问题 I have a scenario in which I have to process multiple .sQL files, every file contains 3-4 insert or Update queries, now when any query in a file fails I do rollback whole transaction means whole file we be rolled back , and all other files executed before that file will get committed, I want an option where user can rollback entire transaction means all queries in a file executed and all files executed before that particular file containing error, and if user wants to skip that particular

Child Parent Transactions roll back

﹥>﹥吖頭↗ 提交于 2019-12-02 07:23:45
I have a scenario in which I have to process multiple .sQL files, every file contains 3-4 insert or Update queries, now when any query in a file fails I do rollback whole transaction means whole file we be rolled back , and all other files executed before that file will get committed, I want an option where user can rollback entire transaction means all queries in a file executed and all files executed before that particular file containing error, and if user wants to skip that particular file with error we will just rollback single file which contains error all other files will get committed,

TransactionScope error in ambient transaction does not rollback the transaction

天涯浪子 提交于 2019-12-02 07:01:11
I use an ambient transaction like this : using(TransactionScope tran = new TransactionScope()) { CallAMethod1();//INSERT CallAMethod2();//INSERT tran.Complete(); } The method CallAMethod2(); returns affected rows =-264 So it fails to insert however the first Insert has been committed ! I want to know how to work with ambient transaction and what if the second method has more than one action which needs internal transaction , should i put these actions in internal transaction ? like this : DAL_Helper.Begin_Transaction(); //------Fill newKeysDictioanry affectedRow = DBUtilities

Passing around a SqlConnection

本小妞迷上赌 提交于 2019-12-02 05:44:45
I have created a TransactionScope and within the scope various items are created and updated in the database. During this process I make a lot of calls to the database. Originally I opened a SqlConnection in the beginning of the TransactionScope and passed it around to any function that made a DB call then I closed the connection after all the calls are made and before the transaction commits. Is it better to do this or to open and close a connection (using the same connection string) for each call? If you're going to make a lot of calls in a row, and it's easy to pass in an open connection,

asp.Net TransactionScope error

有些话、适合烂在心里 提交于 2019-12-02 04:38:41
Here is my coding using (TransactionScope scope = new TransactionScope()) { using (DataAccess.Document Access = new DataAccess.Document()) { if (toSave.Document.Rows.Count > 0) { Access.SaveDocument(docToSave); } if (toUpdate.Document.Rows.Count > 0) { Access.UpdateEachDocument(docToUpdate); } } scope.Complete(); } here is the error ExecuteNonQuery requires an open and available Connection. The connection's current state is closed. Document is a class and there are save and update document methods there. If I comment the transactionScope, I get no errors. What's wrong? Well, it is clearly

Problems with TransactionScope and Oracle

烈酒焚心 提交于 2019-12-01 18:56:57
we have written a C# 3.5 client talking to an Oracle database (11g) using the ODP.NET. This application has a batch process where a long running task is performed making various calls to the database within a TransactionScope. On our development environment all goes well, but at the UAT environment of one of our clients (who has loads of data) two alternating (sometimes the one, sometimes the other...) errors occur: Unable to enlist in a distributed transaction The transaction has aborted. (inner exception: Transaction Timeout) We currently use a time-out of one day for the transaction (for

TransactionScope and SQLite database gets locked

我的梦境 提交于 2019-12-01 17:23:45
I am trying to use Entity Framework 6 with SQLite and running into a database locked issue when trying to use TransactionScope . Here is my code: using (var txn = new TransactionScope()) { using (var ctx = new CalibreContext()) { var book = ctx.Books.First(x => x.Id == 2); var author = ctx.Authors.First(x => x.Id == 3); book.Authors.Add(author); ctx.SaveChanges(); } txn.Complete(); } First line var book = ctx.Books.First(x => x.Id == 2); executes ok. but then once I move on to the next one I get an exception saying that my database is locked. Here is my app config: <configuration>

Ignore SqlTransaction.Commit within TransactionScope

孤街醉人 提交于 2019-12-01 16:45:02
问题 We are in a process of gradually replacing legacy data access code by entity framework (4.3.1). In some occasions we can't avoid using both ways of data access in one unit of work. Ideally, this should be done in one transaction. However, the old code uses SqlTransaction s that call Commit() when a unit of work is done and EF manages its own transactions. So we thought of wrapping "old" and "new" code in a TransactionScope. However, a Commit within a surrounding TransactionScope is always

TransactionScope and SQLite database gets locked

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 16:35:47
问题 I am trying to use Entity Framework 6 with SQLite and running into a database locked issue when trying to use TransactionScope . Here is my code: using (var txn = new TransactionScope()) { using (var ctx = new CalibreContext()) { var book = ctx.Books.First(x => x.Id == 2); var author = ctx.Authors.First(x => x.Id == 3); book.Authors.Add(author); ctx.SaveChanges(); } txn.Complete(); } First line var book = ctx.Books.First(x => x.Id == 2); executes ok. but then once I move on to the next one I