public static void DeriveParameters(OdbcCommand command) { // MDAC 65927 if (null == command) { throw ADP.ArgumentNull("command"); } switch (command.CommandType) { case System.Data.CommandType.Text: throw ADP.DeriveParametersNotSupported(command); case System.Data.CommandType.StoredProcedure: break; case System.Data.CommandType.TableDirect: // CommandType.TableDirect - do nothing, parameters are not supported throw ADP.DeriveParametersNotSupported(command); default: throw ADP.InvalidCommandType(command.CommandType); } if (string.IsNullOrEmpty(command.CommandText)) { throw ADP.CommandTextRequired(ADP.DeriveParameters); } OdbcConnection connection = command.Connection; if (null == connection) { throw ADP.ConnectionRequired(ADP.DeriveParameters); } ConnectionState state = connection.State; if (ConnectionState.Open != state) { throw ADP.OpenConnectionRequired(ADP.DeriveParameters, state); } OdbcParameter[] list = DeriveParametersFromStoredProcedure(connection, command); OdbcParameterCollection parameters = command.Parameters; parameters.Clear(); int count = list.Length; if (0 < count) { for (int i = 0; i < list.Length; ++i) { parameters.Add(list[i]); } } }
public static void DeriveParameters(OdbcCommand command) { OdbcConnection.ExecutePermission.Demand(); if (command == null) { throw ADP.ArgumentNull("command"); } CommandType commandType = command.CommandType; if (commandType == CommandType.Text) { throw ADP.DeriveParametersNotSupported(command); } if (commandType != CommandType.StoredProcedure) { if (commandType == CommandType.TableDirect) { throw ADP.DeriveParametersNotSupported(command); } throw ADP.InvalidCommandType(command.CommandType); } if (ADP.IsEmpty(command.CommandText)) { throw ADP.CommandTextRequired("DeriveParameters"); } OdbcConnection connection = command.Connection; if (connection == null) { throw ADP.ConnectionRequired("DeriveParameters"); } ConnectionState state = connection.State; if (ConnectionState.Open != state) { throw ADP.OpenConnectionRequired("DeriveParameters", state); } OdbcParameter[] parameterArray = DeriveParametersFromStoredProcedure(connection, command); OdbcParameterCollection parameters = command.Parameters; parameters.Clear(); int length = parameterArray.Length; if (0 < length) { for (int i = 0; i < parameterArray.Length; i++) { parameters.Add(parameterArray[i]); } } }
object ICloneable.Clone() { OdbcCommand clone = new OdbcCommand(); clone.CommandText = CommandText; clone.CommandTimeout = this.CommandTimeout; clone.CommandType = CommandType; clone.Connection = this.Connection; clone.Transaction = this.Transaction; clone.UpdatedRowSource = UpdatedRowSource; if ((null != _parameterCollection) && (0 < Parameters.Count)) { OdbcParameterCollection parameters = clone.Parameters; foreach (ICloneable parameter in Parameters) { parameters.Add(parameter.Clone()); } } return(clone); }
object ICloneable.Clone() { OdbcCommand command = new OdbcCommand(); Bid.Trace("<odbc.OdbcCommand.Clone|API> %d#, clone=%d#\n", this.ObjectID, command.ObjectID); command.CommandText = this.CommandText; command.CommandTimeout = this.CommandTimeout; command.CommandType = this.CommandType; command.Connection = this.Connection; command.Transaction = this.Transaction; command.UpdatedRowSource = this.UpdatedRowSource; if ((this._parameterCollection != null) && (0 < this.Parameters.Count)) { OdbcParameterCollection parameters = command.Parameters; foreach (ICloneable cloneable in this.Parameters) { parameters.Add(cloneable.Clone()); } } return(command); }