Azavea.Open.DAO.SQL.AbstractSqlConnectionDescriptor.SetParametersOnCommand C# (CSharp) Method

SetParametersOnCommand() public abstract method

Each driver seems to have its own way of marking parameters ("?", ":param", "@PARAM", etc). So, the database utilities class always uses "?" and relies on the specific descriptor to replace the ? with the appropriate names in the SQL, and also to set the parameters on the command object.
public abstract SetParametersOnCommand ( IDbCommand cmd, IEnumerable parameters ) : void
cmd IDbCommand Database command (with .Text already populated with sql) that needs /// the parameters set on it.
parameters IEnumerable The parameter values, in the order that the ?'s appear in the /// command's text. This collection should not be null.
return void
        public abstract void SetParametersOnCommand(IDbCommand cmd, IEnumerable parameters);

Usage Example

 /// <summary>
 /// Helper to set up a command with sql and parameters and other misc stuff.
 /// </summary>
 private static void SetSQLOnCommand(AbstractSqlConnectionDescriptor connDesc, 
     IDbCommand cmd, string sql, IEnumerable sqlParams)
 {
     if (connDesc == null)
     {
         throw new ArgumentNullException("connDesc", "Connection descriptor cannot be null.");
     }
     if (cmd == null)
     {
         throw new ArgumentNullException("cmd", "Command cannot be null.");
     }
     try
     {
         cmd.CommandType = CommandType.Text;
         cmd.CommandText = sql;
         if (sqlParams != null)
         {
             connDesc.SetParametersOnCommand(cmd, sqlParams);
         }
     }
     catch (Exception e)
     {
         _log.Warn("Unable to set parameters on sql command, " +
                   SqlUtilities.SqlParamsToString(sql, sqlParams), e);
         throw new ApplicationException("Bad parameters for sql statement.", e);
     }
 }