Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filling tables in a dataset
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01123034
Message ID:
01123066
Views:
19
This message has been marked as a message which has helped to the initial question of the thread.
>Could you give me a simple example of a SP that returns two result sets?

this is simply a SP that contains 2 SELECT statements.

>is the adapter smart enough to figure out which result set to use in which table?

The 1st SELECT is table 0, the 2nd is table 1, ...

>Thanks Eric. Could you give me a simple example of a SP that returns two result sets? Oh an by the way my dataset is a typed dataset, is the adapter smart enough to figure out which result set to use in which table?
>
>Thanks,
>Einar
>
>>if your dataset has 2 tables, you can set the TableName property:
>>
>>SqlDataAdapter adapter1 = new SqlDataAdapter("YourSPThatReturnsMultipleResultSets", sqlConnection);
>>adapter1.Fill(myDataSet);
>>myDataSet.Tables[0].TableName = "Table1Name";
>>myDataSet.Tables[1].TableName = "Table2Name";
>>
>>
>>>I have a dataset with two tables. I know I can fill the tables independently using a a data adaper for each of the tables. Something like this:
>>>
>>>MyDataSet myDataSet = new MyDataSet();
>>>
>>>SqlDataAdapter adapter1 = new SqlDataAdapter("SP1", sqlConnection);
>>>adapter1.Fill(myDataSet, myDataSet.Table1.TableName);
>>>
>>>SqlDataAdapter adapter2 = new SqlDataAdapter("SP2", sqlConnection);
>>>adapter2.Fill(myDataSet, myDataSet.Table2.TableName);
>>>
>>>(I think that code would compile <s>)
>>>
>>>Anywho is there a way to construct a stored procedure to return multiple "datasets" so that I can fill both Table1 and Table2 using one stored procedure? (maybe Table1 is the parent table and Table2 is the child table)
>>>
>>>How do you do this?
>>>
>>>Thanks,
>>>Einar
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform