binding multi-table datareader

J

js

I am using executeReader to get a SqlDataReader as in my code below.
The SqlDataReader contains two tables. I am trying to bind each table
to its respective dropdown list control. Thanks.

//************* My code *************
System.Data.SqlClient.SqlDataReader dr = null;

string strSQL =
"SELECT id, iorg_name FROM int_org order by iorg_name;" +
"select id, l_name from loc order by l_name";

oDataBroker.sqlStatement = strSQL;
dr = oDataBroker.getDataFromReader(2);

this.cboOrg.DataSource = dr; //how to specify the first table in the
result?
this.cboOrg.DataTextField = "iorg_name";
this.cboOrg.DataValueField = "id";
this.cboOrg.DataBind();
this.cboOrg.Items.Insert(0,String.Empty);

this.cobLocation.DataSource = dr; //how to specify the second table in
the result?
this.cboLocation.DataTextField = "l_name";
this.cboLocation.DataValueField = "id";
this.cboLocation.DataBind();
this.cboLocation.Items.Insert(0,String.Empty);
 
M

Mohamed Mosalem

Hi,
your code will be as you write but before binding to the secnd control call
the NextResult() function on the datareader object

Regards,
Mohamed Mosalem
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top