TdsMetaParameter.cs - fixes 699643. Note as Mono.Data.TdsClient and Mono.Data.SybaseC...
authorNeale Ferguson <neale@sinenomine.net>
Mon, 12 Dec 2011 14:51:27 +0000 (09:51 -0500)
committerNeale Ferguson <neale@sinenomine.net>
Mon, 12 Dec 2011 14:51:27 +0000 (09:51 -0500)
SqlTransaction.cs - Check if the connection is still active before trying to rollback during Dispose. A loss of a connection is possible which result in an exception that will lead to the closing of the session. This will result in the dispose methods being invoked and if there was an active transaction then a rollback will be attempted. However, if the connection is gone we'll end up raising further exceptions about resources already being disposed.

mcs/class/Mono.Data.Tds/Mono.Data.Tds/TdsMetaParameter.cs
mcs/class/System.Data/System.Data.SqlClient/SqlTransaction.cs

index 931afeafd9efe22609c23127aa32d2262785e4b4..aa5422df5e3bf0708cccaf425567513b8e822f3e 100644 (file)
@@ -218,7 +218,7 @@ namespace Mono.Data.Tds {
                                }
                                
                                if (size > 8000) {
-                                       typeName = "image";
+                                       typeName = "varbinary(max)";
                                }
                        }
                        
@@ -246,7 +246,7 @@ namespace Mono.Data.Tds {
                                break;
                        case "nvarchar":
                        case "xml":
-                               int paramSize = GetActualSize () / 2;
+                               int paramSize = Size < 0 ? GetActualSize () / 2 : Size;
                                result.Append (paramSize > 0 ? (paramSize > 4000 ? "(max)" : String.Format ("({0})", paramSize)) : "(4000)");
                                break;
                        case "char":
index f1b48490cb15216a622d9ce5b9960fdba0c20aa1..9483b3ef6fd0904f97d1bc0b70eba9d963d1041f 100644 (file)
@@ -158,8 +158,9 @@ namespace System.Data.SqlClient
                        if (!isOpen)
                                throw ExceptionHelper.TransactionNotUsable (GetType ());
 
-                       connection.Tds.Execute (String.Format ("IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION {0}",
-                                                               transactionName));
+                       if (connection.Tds.IsConnected)
+                               connection.Tds.Execute (String.Format ("IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION {0}",
+                                                                       transactionName));
                        isOpen = false;
                        connection.Transaction = null;
                        connection = null;