I have two query's. One from one database, and one from another.
The second query uses the first query's data as a table. (This is what I need to know how to do)
The query's more complicated then the example but i tried to make it simple. Example below:
DataTable dt = new DataTable();
OdbcConnection myConnection = salesConnection();
myConnection.Open();
OdbcCommand selectCMD = new OdbcCommand("SELECT CUSTOMER.CUSTOMER_NBR " +
"FROM CUSTOMER", myConnection);
OdbcDataAdapter cmd = new OdbcDataAdapter();
cmd.SelectCommand = selectCMD;
cmd.Fill(dt);
myConnection.Close();
DataTable dtM = new DataTable();
myConnection = mConnection();
myConnection.Open();
selectCMD = new OdbcCommand("SELECT '**DATA TABLE ABOVE**'.CUSTOMER_NBR " +
"FROM '**HOW TO I REFERENCE THE DATA TABLE ABOVE**'",
myConnection);
cmd = new OdbcDataAdapter();
cmd.SelectCommand = selectCMD;
cmd.Fill(dtM);
myConnection.Close();
CUSTOMER_NBRor multiple? In general, use parameters in your second command which are set from the first table's row(s) (you could use a lop if it mcontains multiple rows).