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.
}
if (size > 8000) {
- typeName = "image";
+ typeName = "varbinary(max)";
}
}
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":
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;