c# - Error: The underlying provider failed on Open. How to resolve it? -
I have a function with this type of code:
Var db = new MyDbContext ()) {// A complete bunch of code, DB is working. // Then I try to open other DbContext such as (var dba = new OtherDbContext ()) {// just about 2 lines to get something from a database}}
And then when I get the second DBCTTEX, I get two error messages:
"The underlying provider failed on the open." & Amp; "MSDTT is not available on server 'MySaer'."
Is there any reason why this is happening? Can I open 2DBCTNet at a time?
In the first scenario, you have AnotherDbContext . The connection to each of the databases is opened. When you call your service system with the help of a block, a new connection has been opened within MyDbContextwhile , another open already, this will give your transaction to a distributed transaction Is encouraged, and partially committed data (the result of dba.SaveChanges calls in the service) is not available from your external connection. Also keep in mind that the distributed transaction has slowed down so far and thus, its abusive performance has a side effect. Private Zero btnTwoConnectionsNested_Click (Object Sender, EventArgs E) {string connectionString = @ "Data Source =" + tbServer.Text + @ "; Initial Catalog = Master; Integrated Security = True; Timeout = 0 "; (Using Transaction Sespace Transactions Scope = New Transaction Scope ()) {SQL Connection Connection A = New SQL Connection (Connection String); SqlConnection Connection Two = New SqlConnection (connectionString); Try {// 2 connection, one.Open (nested connection); ConnectionTwo.Open (); // two for DTC with 05 and 08 connection. Stop it (); ConnectionOne.Close (); MessageBox.Show ("Success"); } Hold (Exception pre) {Message Box. Show ("Error:" + East Message); } Finally {connectionOne.Dispose (); ConnectionTwo.Dispose (); Within a transaction scope, it will open two connections, nested result:
Against the SQL Server 2005 instance: MSDTC is unavailable on the server 'server' .
Against the SQL Server 2008 instance: MSDTC is unavailable on the server 'server'.
SQL Server has enhanced DTC for nested connections in both versions, and it has extended.
Nested connections will grow with DTC in SQL Server 2005 and 2008. Time will increase with DTC in 2005, but will not be in 2008.
Comments
Post a Comment