?
Solved

Dataset filled with two Stored Procedures

Posted on 2012-03-26
14
Medium Priority
?
340 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

764 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