Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dataset filled with two Stored Procedures

Posted on 2012-03-26
14
Medium Priority
?
341 Views
Last Modified: 2012-03-28
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
Comment
Question by:mitdaniels
[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
14 Comments
 
LVL 21

Expert Comment

by:Dale Burrell
ID: 37765175
Tricky... any chance you can change them into table valued functions?
0
 
LVL 18

Expert Comment

by:DarrenD
ID: 37765188
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
 
LVL 12

Expert Comment

by:Anuradha Goli
ID: 37765277
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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

Author Comment

by:mitdaniels
ID: 37766665
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
 
LVL 18

Expert Comment

by:DarrenD
ID: 37766680
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
 

Author Comment

by:mitdaniels
ID: 37766929
Unfortunately a good example will take too much time to put together and explain.
0
 

Author Comment

by:mitdaniels
ID: 37766967
Thus far I've heard nothing from the Dataset or ADO.NET gurus, perhaps the solution lies there??
0
 
LVL 18

Assisted Solution

by:DarrenD
DarrenD earned 2000 total points
ID: 37770489
0
 

Author Comment

by:mitdaniels
ID: 37771890
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
 
LVL 18

Assisted Solution

by:DarrenD
DarrenD earned 2000 total points
ID: 37772228
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
 

Author Comment

by:mitdaniels
ID: 37772479
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
 
LVL 18

Accepted Solution

by:
DarrenD earned 2000 total points
ID: 37775600
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
 

Author Comment

by:mitdaniels
ID: 37777284
I think those are the missing pieces, will give it a go today, thanks.
0
 

Author Closing Comment

by:mitdaniels
ID: 37777924
I think you've put me on a path to a solution.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

609 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