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);
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
if (disposed) return;
if (disposing) {
parameters.Clear();
+ if (Connection != null)
+ Connection.DataReader = null;
}
base.Dispose (disposing);
disposed = true;