[Mono-bugs] [Bug 66754][Maj] New - Commiting database transaction results in "transaction not open" error

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 23 Sep 2004 23:11:47 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by crslinyc@hotmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=66754

--- shadow/66754	2004-09-23 23:11:47.000000000 -0400
+++ shadow/66754.tmp.25221	2004-09-23 23:11:47.000000000 -0400
@@ -0,0 +1,108 @@
+Bug#: 66754
+Product: Mono: Class Libraries
+Version: unspecified
+OS: GNU/Linux [Other]
+OS Details: Fedora Core 1
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: Sys.Data
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: crslinyc@hotmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Commiting database transaction results in "transaction not open" error
+
+Description of Problem:  Database transaction problem.  Not certain what 
+the exact problem is, but when inserting into database, after 
+transaction.commit() Mono is possibly trying to dispose of the transaction 
+twice and therefore a "transaction not open" error occurs.  Nonetheless 
+the data gets inserted into the database.  Using Microsoft Data Access 
+Block 2.0 also results in the same error.
+
+
+Steps to reproduce the problem:
+Executing the following code on .Net framework 1.1 works correctly but 
+causes Mono to crash : (Database is MS SQL Server 2000)
+
+string connStr = "server=192.168.1.151; user id=sa; password=admin; 
+database=pubs";
+using (SqlConnection connection = new SqlConnection(connStr))
+{
+	connection.Open();
+	using (SqlTransaction transaction = connection.BeginTransaction())
+	{
+		try
+		{
+			string sSql = "Insert into titles (title_id, 
+title) Values ('AAA000', 'MyTitle')";
+			SqlCommand command = new SqlCommand();
+			command.Connection = connection;
+			command.CommandText = sSql;
+			command.Transaction = transaction;
+			command.CommandType = CommandType.Text;
+			command.ExecuteNonQuery();
+			transaction.Commit();
+		}
+		catch (System.Exception ex)
+		{
+			transaction.Rollback();
+		}
+		finally
+		{
+			connection.Close();
+		}
+
+	}
+}
+
+Actual Results:
+
+An exception occurs and somehow is not caught, but data gets inserted into 
+database. Stack trace below:
+
+Description: Error processing request. 
+Error Message: HTTP 500. 
+
+Stack Trace: System.InvalidOperationException: The Transaction was not 
+open.
+in <0x00049> System.Data.SqlClient.SqlTransaction:Rollback (string)
+in <0x00056> (wrapper remoting-invoke-with-check) 
+System.Data.SqlClient.SqlTransaction:Rollback (string)
+in <0x00013> System.Data.SqlClient.SqlTransaction:Rollback ()
+in <0x0004f> (wrapper remoting-invoke-with-check) 
+System.Data.SqlClient.SqlTransaction:Rollback ()
+in <0x00021> System.Data.SqlClient.SqlTransaction:Dispose (bool)
+in <0x00058> (wrapper remoting-invoke-with-check) 
+System.Data.SqlClient.SqlTransaction:Dispose (bool)
+in <0x00013> System.Data.SqlClient.SqlTransaction:Dispose ()
+in <0x002cf> MonoTransaction.WebForm1:Button1_Click 
+(object,System.EventArgs)
+in <0x00069> (wrapper delegate-invoke) 
+System.MulticastDelegate:invoke_void_object_EventArgs 
+(object,System.EventArgs)
+in <0x0009e> System.Web.UI.WebControls.Button:OnClick (System.EventArgs)
+in <0x00058> 
+System.Web.UI.WebControls.Button:System.Web.UI.IPostBackEventHandler.RaiseP
+ostBackEvent (string)
+in <0x00016> System.Web.UI.Page:RaisePostBackEvent 
+(System.Web.UI.IPostBackEventHandler,string)
+in <0x0003e> System.Web.UI.Page:RaisePostBackEvents ()
+in <0x002c3> System.Web.UI.Page:InternalProcessRequest ()
+in <0x000c2> System.Web.UI.Page:ProcessRequest (System.Web.HttpContext)
+in <0x002eb> ExecuteHandlerState:Execute ()
+in <0x00084> StateMachine:ExecuteState 
+(System.Web.HttpApplication/IStateHandler,bool&)
+
+
+Expected Results:
+Transaction is completed and data inserted with no exceptions.
+
+
+How often does this happen? 
+always
+
+Additional Information: