transactionscope

HRESULT: 0x8004D00E using TransactionScope - C#

随声附和 提交于 2020-01-03 19:14:21
问题 I received the following error when I tried to run a C# WinForms application on a Windows Server 2003 Standard Edition SP1 machine that was connecting to a SQL server 2000, converting the data in the WinForms app and inserting the converted into a SQL server 2005 application. I am connecting to each database using SSPI. The code was contained within a TransactionScope block: System.TimeSpan TransactionTimeOut = new TimeSpan(0, 40, 0); using(TransactionScope Scope = new TransactionScope

The operation is not valid for the state of the transaction

拥有回忆 提交于 2020-01-02 07:24:11
问题 I have a TransactionScope() block. It always gets stuck in an insert statement. It appears in the Activity Monitor as a Blocking Task, so it blocks the SQL server, and after the timeout, I get this error: The operation is not valid for the state of the transaction. What’s going wrong? const TransactionScopeOption opt = new TransactionScopeOption(); TimeSpan span = new TimeSpan(0, 0, 1, 30); try { using (TransactionScope scope01 = new TransactionScope(opt, span)) { using (var sqlcon = new

Does ADO Entity Framework support non DTC transactions? Multiple queries inside one EntityContext and one TransactionScope is causing DTC promotion

做~自己de王妃 提交于 2020-01-01 06:37:47
问题 I have a web application that uses the Entity Framework - we make use of the TransactionScope class to provide ambient transactions. Is there any way to tell EF to use a standard T-SQL transaction in preference to DTC transaction? Quite often we make a number of queries to different tables inside one EntityContext and one TransactionScope instance, however this seems to always promote the transaction to DTC I have put a short example together, see below. The query to the individual table

How can I implement WCF Transaction support on custom class using CoreService?

旧时模样 提交于 2019-12-30 18:07:34
问题 I wrote a class to assist in adding & removing Destinations to a Publication Target using the Core Service. Destinations are normally exposed as a string (with XML content) via the Core Service, so I wrote my own wrappers around that, etc. I now have a situation where I need to update 2 publication targets and thought it would be cool to use a transaction scope to ensure that both targets are updated at the same time. I am however struggling with implementing this. Code working (using

NHibernate TransactionScope issue with Oracle 11g

烈酒焚心 提交于 2019-12-30 09:55:19
问题 The following code snippet works fine with SQL Server 2008 (SP1) but with Oracle 11g the call to session.BeginTransaction() throws an exception with the message ‘Connection is already part of a local or a distributed transaction’ (stack trace shown below). Using the '"NHibernate.Driver.OracleDataClientDriver". Has anyone else run into this? using (var scope = new TransactionScope()) { using (var session = sessionFactory.OpenSession()) using (var transaction = session.BeginTransaction()) { //

TransactionScope, where is begin transaction on sql profiler?

一曲冷凌霜 提交于 2019-12-30 05:57:14
问题 i need to do something like this on a transaction context using(var context = new Ctx()) { using (TransactionScope tran = new TransactionScope()) { decimal debit = 10M; int id = 1; var data = context.Cashier .Where(w => w.ID == id) .Select(s => new{ s.Money }) .Single(); Cashier cashier = new Cashier(){ ID = id }; context.Cashier.Attach(cashier); cashier.Money = data.Money - debit; context.Entry(cashier).Property(p => p.Money ).IsModified = true; context.SaveChanges(SaveOptions.None); tran

Is it possible to use System.Transactions.TransactionScope with SqlBulkCopy?

点点圈 提交于 2019-12-30 00:14:48
问题 Very simple question: is it possible to use System.Transactions.TransactionScope together with SqlBulkCopy ? The documentation Transaction and Bulk Copy Operations doesn't mention anything (at least as of .NET 4.0) and my testing indicates it does not automatically enlist with TransactionScope . 回答1: SqlBulkCopy never enlists into a transaction. SqlCommand also does not do that. Common misconception. The enlistment is performed at the time SqlConnection.Open is called. After that, anything

TransactionScope() in Sql Azure

♀尐吖头ヾ 提交于 2019-12-29 08:13:28
问题 Does Sql Azure support using TransactionScope() when performing inserts? Below is a code snippet of what I am trying to do. using (var tx = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions() { IsolationLevel = IsolationLevel.ReadCommitted })) { using (var db = MyDataContext.GetDataContext()) { try { MyObject myObject = new MyObject() { SomeString = "Monday" }; db.MyObjects.InsertOnSubmit(myObject); db.SubmitChanges(); tx.Complete(); } catch (Exception e) { } } }

EF and TransactionScope for both SQL Server and Oracle without escalating/spanning to DTC?

心已入冬 提交于 2019-12-29 01:27:31
问题 Can anyone update me on this topic? I want to support both SQL Server and Oracle in my application. Is it possible to have the following code (in BL) working for both SQL Server and Oracle without escalating/spanning to distributed transactions (DTC) ? // dbcontext is created before, same dbcontext will be used by both repositories using (var ts = new TransactionScope()) { // create order - make use of dbcontext, possibly to call SaveChanges here orderRepository.CreateOrder(order); // update

EF and TransactionScope for both SQL Server and Oracle without escalating/spanning to DTC?

你。 提交于 2019-12-29 01:26:09
问题 Can anyone update me on this topic? I want to support both SQL Server and Oracle in my application. Is it possible to have the following code (in BL) working for both SQL Server and Oracle without escalating/spanning to distributed transactions (DTC) ? // dbcontext is created before, same dbcontext will be used by both repositories using (var ts = new TransactionScope()) { // create order - make use of dbcontext, possibly to call SaveChanges here orderRepository.CreateOrder(order); // update