The transaction has already been implicitly or explicitly committed or aborted.
-
Hi, I have been getting this error when trying to open a connection within transactionScope of .net 2.0. "The transaction has already been implicitly or explicitly committed or aborted." I have visual studio 2.0 Professional and am using C# for class library that I am working on. I get this error when trying to open the connection to SQL Server 2000. Any help would be greatly appreciated. if it helps here is my code. myID.GetNextID(); is the method where error occurs. I am opening a sql server connction and execute the stored procedure in this method. When i try to open the connection, that is where the error occurs "The transaction has already been implicitly or explicitly committed or aborted" public void Execute() { MyID myID = new MyID() DataTable myRecords = GetRecords(); foreach (DataRow dr in myRecords.Rows) { using (TransactionScope scope = new TransactionScope()) { int idint= myID.GetNextID(); string summaryUpdateQuery = "UPDATE tblSummarySample SET ID= " + idint+ " WHERE ServiceID= " + dr["mySampleID"].ToString(); UpdateSummaryRecord(summaryUpdateQuery); string detailUpdateQuery = "UPDATE tblDetailSample SET TransID = " + idint+ " WHERE ServiceID= " + dr["mySampleID"].ToString(); UpdateMyRecords(detailUpdateQuery); scope.Complete(); } } }
Thanks Needy
-
Hi, I have been getting this error when trying to open a connection within transactionScope of .net 2.0. "The transaction has already been implicitly or explicitly committed or aborted." I have visual studio 2.0 Professional and am using C# for class library that I am working on. I get this error when trying to open the connection to SQL Server 2000. Any help would be greatly appreciated. if it helps here is my code. myID.GetNextID(); is the method where error occurs. I am opening a sql server connction and execute the stored procedure in this method. When i try to open the connection, that is where the error occurs "The transaction has already been implicitly or explicitly committed or aborted" public void Execute() { MyID myID = new MyID() DataTable myRecords = GetRecords(); foreach (DataRow dr in myRecords.Rows) { using (TransactionScope scope = new TransactionScope()) { int idint= myID.GetNextID(); string summaryUpdateQuery = "UPDATE tblSummarySample SET ID= " + idint+ " WHERE ServiceID= " + dr["mySampleID"].ToString(); UpdateSummaryRecord(summaryUpdateQuery); string detailUpdateQuery = "UPDATE tblDetailSample SET TransID = " + idint+ " WHERE ServiceID= " + dr["mySampleID"].ToString(); UpdateMyRecords(detailUpdateQuery); scope.Complete(); } } }
Thanks Needy
Your code doesn't show what is happening. What is myID.GetNextID() doing? There is very little database access code in the snippet you provided so it is difficult to gauge the likely state of the database at the point of failure. Also, your code is susceptable to a SQL Injection Attack, you may wish to consider using parameterised queries at a minimum to offset the chance of an attack.
*** Developer Day 4 in Reading, England on 2nd December 2006 - Registration Now Open *** Upcoming Scottish Developers events: * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos
-
Your code doesn't show what is happening. What is myID.GetNextID() doing? There is very little database access code in the snippet you provided so it is difficult to gauge the likely state of the database at the point of failure. Also, your code is susceptable to a SQL Injection Attack, you may wish to consider using parameterised queries at a minimum to offset the chance of an attack.
*** Developer Day 4 in Reading, England on 2nd December 2006 - Registration Now Open *** Upcoming Scottish Developers events: * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos
I found the solution to the problem. go to Administrative tools Component Servers MyComputer (right click) go to properties MSDTC TAB Click on Security Configuration Button Make sure Network DTS Access, Allow Remote Access, Allow Inbound, Allow Outbound, Enable Transaction Internet Protocol (TIP) Transactions are CHECKED. Most important of all is No authentication Required option. This option should be selected otherwise even if all of the above check boxes are selected, the exception will not go away. Somehow error description is completely different than "NO Authentican Required" radio button. Anyway, I would wanted to post the solution so others can benefit.
Thanks Needy
-
I found the solution to the problem. go to Administrative tools Component Servers MyComputer (right click) go to properties MSDTC TAB Click on Security Configuration Button Make sure Network DTS Access, Allow Remote Access, Allow Inbound, Allow Outbound, Enable Transaction Internet Protocol (TIP) Transactions are CHECKED. Most important of all is No authentication Required option. This option should be selected otherwise even if all of the above check boxes are selected, the exception will not go away. Somehow error description is completely different than "NO Authentican Required" radio button. Anyway, I would wanted to post the solution so others can benefit.
Thanks Needy
bemahesh wrote:
I found the solution to the problem.
Are you sure?
bemahesh wrote:
Most important of all is No authentication Required option. This option should be selected otherwise even if all of the above check boxes are selected, the exception will not go away.
Does it really solve your problem or does it just make the exception "go away"? What makes it go away? How does this solution work? I don't mean to be difficult, but it looks to me that you've found some controls to fiddle with and in a certain state your exception goes away, but I don't see an explanation of why it makes the exception go away. Unless you can explain why this works, and why it will continue to work, you've effectively built your house on the sand. If you do know why this works, then you might want to explain to better educate those that come after you.
*** Developer Day 4 in Reading, England on 2nd December 2006 - Registration Now Open *** Upcoming Scottish Developers events: * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos
-
bemahesh wrote:
I found the solution to the problem.
Are you sure?
bemahesh wrote:
Most important of all is No authentication Required option. This option should be selected otherwise even if all of the above check boxes are selected, the exception will not go away.
Does it really solve your problem or does it just make the exception "go away"? What makes it go away? How does this solution work? I don't mean to be difficult, but it looks to me that you've found some controls to fiddle with and in a certain state your exception goes away, but I don't see an explanation of why it makes the exception go away. Unless you can explain why this works, and why it will continue to work, you've effectively built your house on the sand. If you do know why this works, then you might want to explain to better educate those that come after you.
*** Developer Day 4 in Reading, England on 2nd December 2006 - Registration Now Open *** Upcoming Scottish Developers events: * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos
well, I am not an expert at TransactionScope. I just started using it for first time ever using .net 2.0. I may not be able to answer your questions since it seems your knowledge in the area may be greater than me. However, I was googaling for exception message and found out that if these settings are checked but didn't mention No authentication Required. I tried checking the check boxes but couldn't get transaction scope to work. I was still getting the exception. At the end, I tried checking the No authentication requiered option (radio button). and, that worked (what i mean by working or GO AWAY is that when i try to open the connection it indeed opens the connection and doesn't throw the exception stating "the transaction.....blah blah blah". I tried executing the update statements and they indeed executed as expected. I may be ignorent or missing some important implications you may have suggested (in terms of security?). Please educate me further. I will be waiting for further input thanks a lot
Thanks Needy
-
well, I am not an expert at TransactionScope. I just started using it for first time ever using .net 2.0. I may not be able to answer your questions since it seems your knowledge in the area may be greater than me. However, I was googaling for exception message and found out that if these settings are checked but didn't mention No authentication Required. I tried checking the check boxes but couldn't get transaction scope to work. I was still getting the exception. At the end, I tried checking the No authentication requiered option (radio button). and, that worked (what i mean by working or GO AWAY is that when i try to open the connection it indeed opens the connection and doesn't throw the exception stating "the transaction.....blah blah blah". I tried executing the update statements and they indeed executed as expected. I may be ignorent or missing some important implications you may have suggested (in terms of security?). Please educate me further. I will be waiting for further input thanks a lot
Thanks Needy
This settings are to make windows safer. Check more on this [here in my post].