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);
}
}