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

QueryIntoDataSet() public static method

Queries for data and populates the specified dataset. If you do not have a dataset already, call QueryForDataSet instead.
public static QueryIntoDataSet ( AbstractSqlConnectionDescriptor connDesc, string dataTableName, string sql, IEnumerable sqlParams, DataSet fillMe ) : void
connDesc AbstractSqlConnectionDescriptor 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 System.Data.DataSet The dataset to put data into. Must not be null.
return 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);
            }
        }