public static QueryIntoDataSet ( |
||
connDesc | The database connection descriptor. This will be /// used to get the database connection. | |
dataTableName | string | 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. |
sql | string | The parameterized SQL query (?'s for values). |
sqlParams | IEnumerable | A list of objects to use as parameters /// to the SQL statement. The list may be /// null if there are no parameters. |
fillMe | The dataset to put data into. Must not be null. | |
리턴 | void |
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);
}
}