Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > bind multiple data tables from sql queries to multiple datacontainers?

Reply
Thread Tools

bind multiple data tables from sql queries to multiple datacontainers?

 
 
Daves
Guest
Posts: n/a
 
      01-05-2006
a SQL query can return multiple data tables eg
SELECT expression1 ...
SELECT expression2 ...

Can I in ASP.Net utilise this to do fewer data fetches from the server, e.g.
selectively binding table1 to gridview1, table2 to gridview2 etc?


 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      01-06-2006
Daves,

The short answer is yes.

I'm sure there will be a few changes with .NET 2.0 but here's how I did it
in .NET 1.1:

Dim SqlCommand As New SqlClient.SqlCommand
SqlCommand.CommandText = "SELECT * FROM authors; SELECT * FROM publishers"
SqlCommand.CommandType = CommandType.Text
SqlCommand.Connection = SqlConnection1

Dim DataAdapter As New SqlClient.SqlDataAdapter(SqlCommand)

Dim DataSet As New DataSet
DataAdapter.Fill(DataSet)

DropDownList1.DataSource = DataSet.Tables(0)
DropDownList1.DataTextField = "au_lname"
DropDownList1.DataValueField = "au_id"
DropDownList1.DataBind()

DropDownList2.DataSource = DataSet.Tables(1)
DropDownList2.DataTextField = "pub_name"
DropDownList2.DataValueField = "pub_id"
DropDownList2.DataBind()

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Daves" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>a SQL query can return multiple data tables eg
> SELECT expression1 ...
> SELECT expression2 ...
>
> Can I in ASP.Net utilise this to do fewer data fetches from the server,
> e.g. selectively binding table1 to gridview1, table2 to gridview2 etc?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Reference, SQL Queries, SQL help ecoolone ASP .Net 0 01-03-2008 10:58 AM
xslt queries in xml to SQL queries Ian Roddis Python 3 02-26-2006 06:49 PM
Using a data-bind dropdownlist to populate another data-bind dropdownlist mr2_93 ASP .Net 1 10-02-2005 05:07 PM
Queries on tables from different data sources John ASP .Net 1 07-01-2004 09:25 PM
Queries on tables from different data sources John ASP .Net Web Services 1 06-28-2004 11:23 PM



Advertisments