In the past two days, I tried Ms DTC, installed two SQL Server servers on two computers, and compiled a transaction processing component bankservice: [Transaction (transactionoption. Required)]
Public Class Bankservice: system. enterpriseservices. servicedcomponent
{
Public Bankservice ()
{
}
Public Void Drawmoneyfroma ( Long Amount)
{
Sqlconnection CN = New Sqlconnection ( " Data Source = ekeen; uid = sa; Pwd = sa; initial catalog = Bank " );
Sqlcommand cmd = New Sqlcommand ( " Update accounts set amount = (amount " + Amount. tostring () + " ) Where accountid = 'A' " , CN );
Try
{
CN. open ();
Cmd. executenonquery ();
}
Catch (Exception ex)
{
ThrowEx;
}
Finally
{
CN. Close ();
}
}
Public Void Depositmoneytob ( Long Amount)
{
Sqlconnection CN = New Sqlconnection ( " Server = (local); Integrated Security = true; initial catalog = Bank " );
Sqlcommand cmd = New Sqlcommand ( " Update accounts set amount = Amount + " + Amount. tostring () + " Where accountid = 'B' " , CN );
CN. open ();
Cmd. executenonquery ();
CN. Close ();
}
[AutoComplete]
Public Void Testdtc ()
{
Drawmoneyfroma (100);
Depositmoneytob (100);
}
}
However, when I call the testdtc () method to test DTC, the CN in the drawmoneyfroma method is executed. when the open method is used, an exception is thrown. "The partner Transaction Manager has disabled remote/network transaction support." No reason is found.
Later, I right-click "my computer" in the component configuration. When selecting properties, I found that the "MSDTC" tab had a default Coordinator option. As a result, I thought whether a computer should be designated as the coordinator, so I entered the name of another test machine, ekeen, and OK. The result is a nightmare: the error "COM + cannot talk to Microsoft Distributed Transaction Coordinator" occurs every time a transaction is executed ". I think the configuration was wrong, but when I want to configure MSDTC again, I find that I can no longer open the tab ~~~.
In desperation, I went to see the event viewer and found that there is a COM + error. According to the results, I found a KB article http://support.microsoft.com /? Kbid = 867520, which indicates the solution:
1. Delete the keys in the registry:
• |
HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ MSDTC |
• |
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ MSDTC |
• |
Hkey_classes_root \ CID |
2. Stop MSDTC: net stop MSDTC
3. Uninstall the MSDTC Service: MSDTC-uninstall
4. reinstall the MSDTC Service: MSDTC-install
5. restart the computer
After the problem is solved, you can configure MSDTC, but the problem of "the partner Transaction Manager has disabled its support for remote/network transactions" still persists. I don't know who can help me, thank you.
My operating system is Windows 2003 and the database is SQL Server 2003 + SP3