473,395 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Returning complex data relationships from a stored procedure.

To minimize database calls, I would like to have a single stored procedure
return all the data necessary to display on my page. This information is
related from several different tables and what I would like to do is to
match the information loaded into a DataSet with the information in the
database. For instance, suppose that I have a Customer table and an Order
table. I would like to return a single customer and all their orders in a
single shot to display. I would like to take advantage of the DataSets
ability of handle relationships. What is the accepted practice for turning
the information from a stored procedure into a DataSet with complex
relationships? Is there any automatic process that will do this?
Nov 17 '05 #1
1 1899
Peter,

There isn't any automatic process to handle this. However, it's not
that hard to do. First, your stored procedure should return two result
sets. Those result sets are the parent and the child rows (do not join them
into one mega-table, keep them separate).

Then, on the client side, use the data set designer to create the typed
data set which includes the two tables. If the relationship between them
(foreign key and primary key) exists on the server, then when you drag the
tables to the data set designer, the relationship should be created for you
as well. If not, then create it yourself in the designer.

Then, all you have to do is create your data adapter with your call to
your stored procedure. Once you do that, you just pass an instance of your
typed data set to your adapter, and it should load the data correctly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:uM**************@TK2MSFTNGP14.phx.gbl...
To minimize database calls, I would like to have a single stored procedure
return all the data necessary to display on my page. This information is
related from several different tables and what I would like to do is to
match the information loaded into a DataSet with the information in the
database. For instance, suppose that I have a Customer table and an Order
table. I would like to return a single customer and all their orders in a
single shot to display. I would like to take advantage of the DataSets
ability of handle relationships. What is the accepted practice for
turning
the information from a stored procedure into a DataSet with complex
relationships? Is there any automatic process that will do this?

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michael Trosen | last post by:
Hi Everyone, I hope someone can help, I'm pretty new to pro*c programming. I have the following application setup: a pro*c program calls a stored procedure and recieves a cursor back: the...
6
by: Samuel Hon | last post by:
Hi I'm not sure what the best approach for this is: I have a stored procedure which I would like to use to return several output values instead of returning a recordset. CREATE PROCEDURE...
5
by: rhungund | last post by:
Hi All. My question is this. I have a complex stored procedure in SQL Server which works fine when I run it in Query Analyzer. However, when I call it within my ASP script, it returns nothing,...
2
by: serge | last post by:
My project is to automate testing of Stored Procedures of type SELECT (at least for now). I want to create a table where each stored procedure's input parameter values are entered and in another...
1
by: Todd Peterson | last post by:
I'm a newbie to DB2 and am trying to figure out how to write a stored procedure, using dynamic SQL statements to return a result set. I believe the majority of the hurdles I have been facing might...
3
by: Mike P | last post by:
Is it possible to return a dataset from a stored procedure, or would you need to write the SQL in your .cs file to return the dataset? Any assistance would be really appreciated. Cheers, ...
1
by: j090757 | last post by:
Returning parm data to vb.net from AS400 stored procedure This example loads a textbox which is used by javascript for error handling. First create the stored procedure on the AS400: CREATE...
11
by: Ron L | last post by:
I have a data table that lists a series of items in my database. In my user form, I want the user to be able to filter by a number of criteria (e.g. location, contract, date modified, etc). Other...
4
by: scparker | last post by:
Hello, We have a stored procedure that does a basic insert of values. I am then able to retrieve the ID number created for this new record. We are currently using ASP.NET 2.0 and use N-Tier...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.