Azavea.Open.DAO.SQL.SqlConnectionUtilities.SetSQLOnCommand C# (CSharp) Method

SetSQLOnCommand() private static method

Helper to set up a command with sql and parameters and other misc stuff.
private static SetSQLOnCommand ( AbstractSqlConnectionDescriptor connDesc, IDbCommand cmd, string sql, IEnumerable sqlParams ) : void
connDesc AbstractSqlConnectionDescriptor
cmd IDbCommand
sql string
sqlParams IEnumerable
return void
        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);
            }
        }