Solved

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

Posted on 2004-04-28
5
638 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

628 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