• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

Dataset filled with two Stored Procedures

I would like to have two Stored Procedures data brought together into a single Dataset, how do I do this? One of the SP requires a Parameter value.

Please provide a typical ASP.NET / ADO.NET / SQL Server example.
0
mitdaniels
Asked:
mitdaniels
3 Solutions
 
Dale BurrellCommented:
Tricky... any chance you can change them into table valued functions?
0
 
DarrenDCommented:
Hi,

If you have the same number of columns in each query then you cold use a UNION statement in SQL


http://www.w3schools.com/sql/sql_union.asp

http://www.techonthenet.com/sql/union.php

There are many references on the web if you do a quick search for SQL Union

Cheers,

Darren
0
 
Anuradha GoliCommented:
Retrieve the data from tables in 2 queries and then UNION them in stored procedure in SQL Server.

In Visual Studio ,attach the dataset to grid in asp.net using ADO.Net

http://asmaqureshi.blogspot.com/2010/01/fill-dataset-with-storedprocedure.html
0
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
mitdanielsAuthor Commented:
Thanks for the input experts.

The one Stored Procedure does JOINS on numerous tables, and the problem lies with not being able to JOIN one table, which only has two columns, while the JOINED SP has many more columns, so a UNION is perhaps unlikely??
0
 
DarrenDCommented:
Hi,

I think you might have to put up an example of the data so that we can see what we have to work with.

Cheers,

Darren
0
 
mitdanielsAuthor Commented:
Unfortunately a good example will take too much time to put together and explain.
0
 
mitdanielsAuthor Commented:
Thus far I've heard nothing from the Dataset or ADO.NET gurus, perhaps the solution lies there??
0
 
DarrenDCommented:
0
 
mitdanielsAuthor Commented:
Thanks, that looks like it might work if I can pull certain columns out to make two DataTables that have the same schema, can that be done? What is the step before the DataTable?
0
 
DarrenDCommented:
Hi,

You will have to create the schemas for the two data tables. I'm not sure I understand the Question "What is the step before the DataTable?"

1. Get the data from the 1st stored procedure into a datatable and load it into your schema using the columns you need.

2. Get the data from the 2nd stored procedure into a datatable

3. Merge the datatables

From the 1st link that I sent it appears possible to merge tables that do not have the same schema which is what you were basically talking about in your original post where you spoke of two different stored procedures with different numbers of columns.

Cheers,

Darren
0
 
mitdanielsAuthor Commented:
Thanks Darren,

The step before the DataTable is it getting the Dataset, or is it possible to use an existing Datareader, this might be a silly question, since I am not really sure how these Dataset features all work together, and  what relationship they have with the DataReader in this instance.

For some reason I get the impression that the DataTable can be used independently of any Dataset, but that might not be so.
0
 
DarrenDCommented:
Hi again,

A DataSet can contain many DataTables, just like a database and also allows you to add relations between DataTables in the DataSet. So you could have order and customer tables and then link them together using a foregin key like order.orderid = customer.orderid

This shows you how to load a DataTable using a DataReader.
http://imar.spaanjaars.com/406/filling-a-datatable-or-dataset-the-quick-way

http://msdn.microsoft.com/en-us/library/ms171920%28v=vs.80%29.aspx

Hope this helps,

Darren
0
 
mitdanielsAuthor Commented:
I think those are the missing pieces, will give it a go today, thanks.
0
 
mitdanielsAuthor Commented:
I think you've put me on a path to a solution.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now