Jelajahi Sumber

* SqlConnection.cs: BeginTransaction does not handle
IsolationLevel.Unspecified, so the default is set as ReadCommited.
Thanks to Jerome Haltom <[email protected]> for this patch.
Fixes bug # 333082.
* SqlTransaction.cs: If transaction count is greater then 0 then roll
back. Thanks to Jerome Haltom <[email protected]> for this
patch. Fixes bug # 331953.

svn path=/trunk/mcs/; revision=87659

Nagappan Alagappan 18 tahun lalu
induk
melakukan
741bd7514a

+ 10 - 0
mcs/class/System.Data/System.Data.SqlClient/ChangeLog

@@ -1,3 +1,13 @@
+2007-10-17  Nagappan <[email protected]> 
+
+	* SqlConnection.cs: BeginTransaction does not handle
+	  IsolationLevel.Unspecified, so the default is set as ReadCommited.
+	  Thanks to Jerome Haltom <[email protected]> for this patch. Fixes
+	  bug # 333082.
+	* SqlTransaction.cs: If transaction count is greater then 0 then roll back.
+	  Thanks to Jerome Haltom <[email protected]> for this patch. Fixes
+	  bug # 331953.
+
 2007-10-15  Gert Driesen  <[email protected]>
 
 	* SqlException.cs: Do not hide Message on 2.0 profile. Fixes bug

+ 4 - 3
mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs

@@ -342,9 +342,6 @@ namespace System.Data.SqlClient {
 
 			string isolevel = String.Empty;
 			switch (iso) {
-			case IsolationLevel.ReadCommitted:
-				isolevel = "READ COMMITTED";
-				break;
 			case IsolationLevel.ReadUncommitted:
 				isolevel = "READ UNCOMMITTED";
 				break;
@@ -354,6 +351,10 @@ namespace System.Data.SqlClient {
 			case IsolationLevel.Serializable:
 				isolevel = "SERIALIZABLE";
 				break;
+			case IsolationLevel.ReadCommitted:
+			default:
+				isolevel = "READ COMMITTED";
+				break;
 			}
 
 			tds.Execute (String.Format ("SET TRANSACTION ISOLATION LEVEL {0};BEGIN TRANSACTION {1}", isolevel, transactionName));

+ 2 - 1
mcs/class/System.Data/System.Data.SqlClient/SqlTransaction.cs

@@ -143,7 +143,8 @@ namespace System.Data.SqlClient
 			if (!isRolledBack) {
 				if (!isOpen)
 					throw new InvalidOperationException ("The Transaction was not open.");
-				connection.Tds.Execute (String.Format ("ROLLBACK TRANSACTION {0}", transactionName));
+				connection.Tds.Execute (String.Format ("IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION {0}",
+				                                       transactionName));
 				isRolledBack = true;
 				isOpen = false;
 				connection.Transaction = null;