A little help with my program would be greatly appreciated!
In my program below, I'm writing every record I select from MBRHISTDETL to a datatable.  However, whenever a record is read from the MBRHISTDTL file, I'd like to perform more actions before writing it to the datatable.  The way the program is written, though, it will write the whole resultset to the datatable when I only want particular records being written.  How can I change this?  What I'd like to do is this:

1. Select a record from MBRHISTDETL
2. Is it BILLTYPE 09 and is BILLMOYR <> 9999?  If yes, continue.  If not, get another record.
3. Use MBRNUM from MBRHISTDETL to get LOCATION, DISTRICT, and CYCLE from LOCINFODETL.
4. Does DISTRICT and CYCLE match the input parameters cbDistrict and cbCycle?  If no, get another record.
5. Populate datatable
6. Go back to 1 unless end of file.

As my code is written right now, I can only complete steps 1 through 3 because I haven't figured out a way to grab a record from MBRHISTDETL and use that info to select another record from LOCINDODETL to verify the record I have is correct before writing to the datatable.  Basically, I'm trying to get information from two different database files and write the information to a datatable.  Am I going about this the right way?

Here's my code so far:

    private void btnGo_Click(object sender, EventArgs e)
        {
            //get parameters
            string cycle = cbCycle.Text;
            string district = cbDistrict.Text;
            
            //create a connection to the database
            OdbcConnection DbConnection = new OdbcConnection("DSN=UPN2;uid=xxxx;pwd=xxxx");
            DbConnection.Open();

            //create a command to extract the required data and
            //assign it to the connection string
            OdbcCommand DbCommand = DbConnection.CreateCommand();
            DbCommand.CommandText = "SELECT * FROM CAV_MBRHISTDETL WHERE BILLTYPE = '09' " +
                "AND BILLMOYR <> '9999'";

            //Create a DataAdapter to run the command and fill the datatable
            OdbcDataAdapter da = new OdbcDataAdapter();
            da.SelectCommand = DbCommand;
            DataTable dt = new DataTable();

            //Put results into datatable.
            da.Fill(dt);


            tbOutput.Text = PrintDataTable(dt);

            DbCommand.Dispose();
            DbConnection.Close();

        }


A little help with my program would be greatly appreciated!
===

In my program below, I'm writing every record I select from MBRHISTDETL to a datatable.  However, whenever a record is read from the MBRHISTDTL file, I'd like to perform more actions before writing it to the datatable.  The way the program is written, though, it will write the whole resultset to the datatable when I only want particular records being written.  How can I change this?  What I'd like to do is this:

1. Select a record from MBRHISTDETL
2. Is it BILLTYPE 09 and is BILLMOYR <> 9999?  If yes, continue.  If not, get another record.
3. Use MBRNUM from MBRHISTDETL to get LOCATION, DISTRICT, and CYCLE from LOCINFODETL.
4. Does DISTRICT and CYCLE match the input parameters cbDistrict and cbCycle?  If no, get another record.
5. Populate datatable
6. Go back to 1 unless end of file.

As my code is written right now, I can only complete steps 1 through 3 because I haven't figured out a way to grab a record from MBRHISTDETL and use that info to select another record from LOCINDODETL to verify the record I have is correct before writing to the datatable.  Basically, I'm trying to get information from two different database files and write the information to a datatable.  Am I going about this the right way?

Here's my code so far:

    private void btnGo_Click(object sender, EventArgs e)
        {
            //get parameters
            string cycle = cbCycle.Text;
            string district = cbDistrict.Text;
            
            //create a connection to the database
            OdbcConnection DbConnection = new OdbcConnection("DSN=UPN2;uid=xxxx;pwd=xxxx");
            DbConnection.Open();

            //create a command to extract the required data and
            //assign it to the connection string
            OdbcCommand DbCommand = DbConnection.CreateCommand();
            DbCommand.CommandText = "SELECT * FROM CAV_MBRHISTDETL WHERE BILLTYPE = '09' " +
                "AND BILLMOYR <> '9999'";

            //Create a DataAdapter to run the command and fill the datatable
            OdbcDataAdapter da = new OdbcDataAdapter();
            da.SelectCommand = DbCommand;
            DataTable dt = new DataTable();

            //Put results into datatable.
            da.Fill(dt);


            tbOutput.Text = PrintDataTable(dt);

            DbCommand.Dispose();
            DbConnection.Close();

        }

