X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Data%2FSystem.Data.SqlClient%2FSqlCommand.cs;h=b0962359876ee29436e75ccbf9974bb4459915db;hb=cb091188403237aa3eb87f39a09f00f642750cc2;hp=338680db3275d712a20e1f3e3329da8e88cee8e3;hpb=b87c7e29df7d04e3199e224c8b8e9a41292cec1b;p=mono.git diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs index 338680db327..b0962359876 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs @@ -434,10 +434,14 @@ namespace System.Data.SqlClient { string procName = CommandText; string schemaName = String.Empty; - int dotPosition = procName.IndexOf ('.'); + int dotPosition = procName.LastIndexOf ('.'); + + // Procedure name can be: [database].[user].[procname] if (dotPosition >= 0) { schemaName = procName.Substring (0, dotPosition); procName = procName.Substring (dotPosition + 1); + if ((dotPosition = schemaName.LastIndexOf ('.')) >= 0) + schemaName = schemaName.Substring (dotPosition + 1); } procName = EscapeProcName (procName, false); @@ -588,9 +592,15 @@ namespace System.Data.SqlClient { this.behavior = behavior; if ((behavior & CommandBehavior.SequentialAccess) != 0) Tds.SequentialAccess = true; - Execute (true); - Connection.DataReader = new SqlDataReader (this); - return Connection.DataReader; + try { + Execute (true); + Connection.DataReader = new SqlDataReader (this); + return Connection.DataReader; + } catch { + if ((behavior & CommandBehavior.CloseConnection) != 0) + Connection.Close (); + throw; + } } public @@ -696,6 +706,8 @@ namespace System.Data.SqlClient { if (disposed) return; if (disposing) { parameters.Clear(); + if (Connection != null) + Connection.DataReader = null; } base.Dispose (disposing); disposed = true;