Solved

How to populate multiple recordsets returned by stored procedure into separate datasets.

Posted on 2004-04-28
5
635 Views
Last Modified: 2010-05-18
I am creating a windows application using visual studio .net. I have a stored procedure that returns 2 recordsets. I want to populate these returned recordsets into two different datasets. for example. if 2 recordsets are returned by my stored procedure, i must be able to populate it into Mydataset1 and Mydataset2.
0
Comment
Question by:binu_star
  • 2
5 Comments
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 10936912
I don't think this possible without copying the returned table yourself in code and then delete it from the original dataset.

But why should you want 2 separate datasets, instead of 1 dataset with 2 tables
0
 
LVL 21

Accepted Solution

by:
tovvenki earned 250 total points
ID: 10937059
Hi,

Try this if you need to populate it into two different datasets.
      DataSet data1,data2;
      SqlDataAdapter adapter = new SqlDataAdapter("MySp",
                  "SERVER=myserver;DATABASE=northwind;UID=sa;");
            
            
      DataSet data = new DataSet();
      adapter.Fill(data);
      data1 = data.Tables[0].DataSet;
      data2 = data.Tables[1].DataSet;

Why do you need to populate it into two datasets??

I hope that this helps you.
Regards,
Venki
0
 
LVL 1

Author Comment

by:binu_star
ID: 11276976
Hi tovvenki,
   Your solution is working. I still want to know if we can make use of only 2 datasets and directly fill them rather than populating into one and then copying to other datasets.
 Thanks,
 Binu
0
 
LVL 21

Expert Comment

by:tovvenki
ID: 11277012
Hi,
what do you mean by "populating into one and then copying to other datasets.". Do you mean to say that use one dataset populate it use the data and then use the same dataset and repopulate it with the next data set??

regards,
venki
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question