Hi,
I am working on vs2005 with sql server 2000. I have used TransactionScope class.
Example Reference:
http://www.c-sharpcorner.com/UploadFile/mosessaur/TransactionScope04142006103850AM/TransactionScope.aspx
The code is given below.
using System.Transactions;
protected void Page_Load(object sender, EventArgs e)
{
System.Transactions.TransactionOptions transOption = new System.Transactions.TransactionOptions();
transOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
transOption.Timeout = new TimeSpan(0, 2, 0);
using (System.Transactions.TransactionScope tranScope = new System.Transactions.TransactionScope(TransactionScopeOption.Required,transOption))
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["nwConnString"].ConnectionString))
{
int i;
con.Open();
SqlCommand cmd = new SqlCommand("update products set unitsinstock=100 where productid=1", con);
i = cmd.ExecuteNonQuery();
if (i > 0)
{
using (SqlConnection conInner = new SqlConnection(ConfigurationManager.ConnectionStrings["pubsConnString"].ConnectionString))
{
conInner.Open();
SqlCommand cmdInner = new SqlCommand("update Salary set sal=5000 where eno=1", conInner);
i = cmdInner.ExecuteNonQuery();
if (i > 0)
{
tranScope.Complete(); // this statement commits the executed query.
}
}
}
}
// Dispose TransactionScope object, to commit or rollback transaction.
}
}
It gives error like
"The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)"
The database I have used is northwind database and pubs database which is by default in sql server 2000.
So, Kindly let me know how to proceed further.
Thanks in advance,
Arun.
Hi,
From your description, it seems that you met the "The partner transaction manager has disabled" error when you want to run the distributed transaction in your project, right?
Generally, the cause of the issue is that you didn't set the transaction service properly. You may following the steps below:
First verify the "Distribute Transaction Coordinator" Service is
running on both database server computer and client computers
1. Go to "Administrative Tools > Services"
2. Turn on the "Distribute Transaction Coordinator" Service if it is not runningIf it is running and client application is not on the same computer as
the database server, on the computer running database server
1. Go to "Administrative Tools > Component Services"
2. On the left navigation tree, go to "Component Services > Computers
> My Computer" (you may need to double click and wait as some nodes
need time to expand)
3. Right click on "My Computer", select "Properties"
4. Select "MSDTC" tab
5. Click "Security Configuration"
6. Make sure you check "Network DTC Access", "Allow Remote Client",
"Allow Inbound/Outbound", "Enable TIP" (Some option may not be
necessary, have a try to get your configuration)
7. The service will restart
8. BUT YOU MAY NEED TO REBOOT YOUR SERVER IF IT STILL DOESN'T WORK
(This is the thing drove me crazy before)On your client computer use the same above procedure to open the
"Security Configuration" setting, make sure you check "Network DTC
Access", "Allow Inbound/Outbound" option, restart service and computer
if necessary.On you SQL server service manager, click "Service" dropdown, select
"Distribute Transaction Coordinator", it should be also running on
your server computer.
Quoted from community members of MSDN:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=230390&SiteID=1
Thanks.
No comments:
Post a Comment