Network access for DTC

M

mehdi_mousavi

Hi folks,
Consider a client program that uses .NET Framework 2.0, and the
Transaction namespace, to do some update/insert against a given
database using the SQL provider:

using (TransactionScope ts = new TransactionScope())
{
//Do some update/insert commands against some tables...
ts.Complete();
}

When the program is run on the same machine that hosts SQL Server 2005,
everything works fine. However, when the client machine is separated
from the hosting SQL Server 2005 machine, the following error occurs:

"Network access for Distributed Transaction Manager (MSDTC) has been
disabled. Please enable DTC for network access in the security
configuration for MSDTC using the Component Services Administrative
tool."

Would someone please tell me how am I supposed to fix this problem?
Shouldn't it use the "Lightweight Transaction Manager" (LTM) to do the
work???

Any help would be highly appreciated,

Cheers,
Mehdi
 
N

Nicholas Paldino [.NET/C# MVP]

mehdi,

No, it shouldn't use the LTM because you are spreading the transaction
across two machines. You are initiating the transaction on the client, and
involving SQL server, which is on another machine, in the transaction, hence
the need for a DTC.

In order to enable this, you need to go to Component Services and find
"My Computer" in the MMC that comes up. Right click on the computer and
select "Properties". This will give you a property sheet that will allow
you enable network access for DTC.

Hope this helps.
 
J

Jesse Houwing

* Nicholas Paldino [.NET/C# MVP] wrote, On 5-8-2006 5:24:
mehdi,

No, it shouldn't use the LTM because you are spreading the transaction
across two machines. You are initiating the transaction on the client, and
involving SQL server, which is on another machine, in the transaction, hence
the need for a DTC.

It should use the LTM, but it probably isn't because he's using more
than one connection to the database. As long as you're using one
tconnaction per transaction, it should still use LTM.


Do it like this:

using (SqlConnection conn = new SqlConnection(connectionstring))
{
conn.Open();
using (TransactionScope ts = new TransactionScope())
{
tableAdapterA.Connection = conn;
tableAdapterA.SaveTable();

tableAdapterB.Connection = conn;
tableAdapterB.SaveTable();

ts.Complete();
}
}


And you won't be needing DTC at all. Let alone anable potentially
dangarous (they're disabled for a reason) network access to DTC.

Jesse Houwing
 
W

Willy Denoyette [MVP]

Are you sure you only open a single connection in te transaction scope? If
you open multiple connections in the same transaction scope SqlClient will
promote your LWPT to a DTC transaction.

Willy.




| Hi folks,
| Consider a client program that uses .NET Framework 2.0, and the
| Transaction namespace, to do some update/insert against a given
| database using the SQL provider:
|
| using (TransactionScope ts = new TransactionScope())
| {
| //Do some update/insert commands against some tables...
| ts.Complete();
| }
|
| When the program is run on the same machine that hosts SQL Server 2005,
| everything works fine. However, when the client machine is separated
| from the hosting SQL Server 2005 machine, the following error occurs:
|
| "Network access for Distributed Transaction Manager (MSDTC) has been
| disabled. Please enable DTC for network access in the security
| configuration for MSDTC using the Component Services Administrative
| tool."
|
| Would someone please tell me how am I supposed to fix this problem?
| Shouldn't it use the "Lightweight Transaction Manager" (LTM) to do the
| work???
|
| Any help would be highly appreciated,
|
| Cheers,
| Mehdi
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top