By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,939 Members | 1,602 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,939 IT Pros & Developers. It's quick & easy.

Multiple Result Sets in a DataSet from DataAdapter ?

P: n/a
Liz

Anyone have any info on how you can fill a DataSet with mutiple result sets
from a SQL batch ? I know with a dataReader you can use the nextResult
method but I'm lost on how you do this with a dataAdapter ....

TIA ..

L
Oct 12 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You may want to do something like this in C# 2.0:

DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter("select * from authors;
select * from employee",

ConfigurationManager.ConnectionStrings["pubsConnectionString"].ConnectionString);
sda.Fill(ds);

gvAuthors.DataSource = ds.Tables[0]; //gvAuthors = GridView
control
gvAuthors.DataBind();

gvEmployees.DataSource = ds.Tables[1]; //gvEmployees = another
GridView control
gvEmployees.DataBind();


On Oct 11, 7:56 pm, "Liz" <l...@tiredofspam.comwrote:
Anyone have any info on how you can fill a DataSet with mutiple result sets
from a SQL batch ? I know with a dataReader you can use the nextResult
method but I'm lost on how you do this with a dataAdapter ....

TIA ..

L
Oct 12 '06 #2

P: n/a
Hi,

DataAdapter.Fill will do it for you

From MSDN:
When handling batch SQL statements that return multiple results, the
implementation of FillSchema for the .NET Framework Data Provider for OLE DB
retrieves schema information for only the first result. To retrieve schema
information for multiple results, use Fill with the MissingSchemaAction set
to AddWithKey.

So it will create one table per resultset
--
Ignacio Machin
machin AT laceupsolutions.com

"Liz" <li*@tiredofspam.comwrote in message
news:e8**************@TK2MSFTNGP02.phx.gbl...
>
Anyone have any info on how you can fill a DataSet with mutiple result
sets
from a SQL batch ? I know with a dataReader you can use the nextResult
method but I'm lost on how you do this with a dataAdapter ....

TIA ..

L


Oct 12 '06 #3

P: n/a
Liz

"Deepak Khanal" <dk*****@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
You may want to do something like this in C# 2.0:

DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter("select * from authors;
select * from employee",

ConfigurationManager.ConnectionStrings["pubsConnectionString"].ConnectionString);
sda.Fill(ds);

gvAuthors.DataSource = ds.Tables[0]; //gvAuthors = GridView
control
gvAuthors.DataBind();

gvEmployees.DataSource = ds.Tables[1]; //gvEmployees = another
GridView control
gvEmployees.DataBind();

so simple ... don't know why I didn't try that ... thanks ....

Liz
Oct 12 '06 #4

P: n/a
Liz

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:eX**************@TK2MSFTNGP03.phx.gbl...
Hi,

DataAdapter.Fill will do it for you

From MSDN:
When handling batch SQL statements that return multiple results, the
implementation of FillSchema for the .NET Framework Data Provider for OLE
DB
retrieves schema information for only the first result. To retrieve schema
information for multiple results, use Fill with the MissingSchemaAction
set
to AddWithKey.
ok ... I'm still finding my way around with this stuff ... what's the
significance of this part of the picture ?

Liz
Oct 12 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.