/// <summary>
/// Queries for data and populates the specified dataset. If you do not have a dataset
/// already, call QueryForDataSet instead.
/// </summary>
/// <param name="dataTableName">The name of the DataTable to put data into in the DataSet.
/// May be null if you wish to use the default given by the DataAdapter.</param>
/// <param name="sql">The parameterized SQL query (?'s for values).</param>
/// <param name="sqlParams">A list of objects to use as parameters
/// to the SQL statement. The list may be
/// null if there are no parameters.</param>
/// <param name="connDesc">The database connection descriptor. This will be
/// used to get the database connection.</param>
/// <param name="fillMe">The dataset to put data into. Must not be null.</param>
public static void QueryIntoDataSet(AbstractSqlConnectionDescriptor connDesc, string dataTableName, string sql,
IEnumerable sqlParams,
DataSet fillMe)
{
IDbConnection conn = DbCaches.Connections.Get(connDesc);
try
{
IDbCommand cmd = DbCaches.Commands.Get(sql, conn);
try
{
SetSQLOnCommand(connDesc, cmd, sql, sqlParams);
DbDataAdapter adapter = connDesc.CreateNewAdapter(cmd);
if (dataTableName != null)
{
adapter.Fill(fillMe, dataTableName);
}
else
{
adapter.Fill(fillMe);
}
}
catch (Exception e)
{
throw new UnableToRunSqlException("Unable to fill dataset with query: ",
connDesc, sql, sqlParams, e);
}
finally
{
DbCaches.Commands.Return(sql, conn, cmd);
}
}
finally
{
DbCaches.Connections.Return(connDesc, conn);
}
}