473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

binding multi-table datareader

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);

Sep 21 '06 #1
1 1751
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
"js" <an********@yahoo.comwrote in message
news:11********************@e3g2000cwe.googlegroup s.com...
>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);

Sep 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ann Morris | last post by:
INTRODUCTION One of the most powerful aspects of .NET and Windows Forms is data binding. Data binding is the process of associating user interface (UI) elements with a data source to generate a...
1
by: JD Kronicz | last post by:
Hi .. I have an issue I have been beating my head against the wall on for some time. I am trying to use late binding for MS graph so that my end users don't have to worry about having the right...
9
by: Zlatko Matić | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws...
0
by: Ian | last post by:
I have sub-classed the Page class in order to provide some base properties and methods that every page on my site will need access to. I would like to have these things show up in the Simple...
30
by: lgbjr | last post by:
hi All, I've decided to use Options Strict ON in one of my apps and now I'm trying to fix a late binding issue. I have 5 integer arrays: dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as...
0
by: Steven Bolard | last post by:
Hello, I am trying to port my .net 1.1 application to 2.0. I am using vs2005. I am trying to get my webservices to run and although i can compile them and and get wsdl and service descriptions...
1
by: xtseeker | last post by:
We have a multi-threaded .NET application, the problem is that the previous programmer didn't care to have locks on the shared variables. Somehow the application doesn't end up in Locked state on a...
3
by: sekshin8 | last post by:
I am trying to bind fields from the first three records of a query (three records will always be returned by the query) to three textboxes on a windows form. ex. Textbox1.text = row1 column1...
1
by: Larry R | last post by:
Asp.net 2.0. Binding a Gridview. UNtil now, it had been simple BoundColumns, but now I need to have one column show the values of 3 columns ( they are in the same datasource). I thought that I...
15
by: Tom Gur | last post by:
Hi, What is early/late binding ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.