473,395 Members | 2,437 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.

Using a stored procedure and Datasets

HI all,

I'm relatively new to this.
How can I get the results of a SP (returns a recordset) into a dataset

Thanks
Robert
Dec 7 '06 #1
2 1665
It's a while since I did this, but as I recall, the steps are:

* Create your stored procedure
* Instantiate a command object (e.g. a sqlCommand instance if you're using
SQL Server)
* Assign your stored procedure's name to the command object's CommandText
property
* Set the command object's CommandType to
System.Data.CommandType.StoredProcedure
* Create a connection object
* Assign the connection object to the command's Connection property
* Create any parameter objects you might need and assign them to the
command's Parameters collection using .Add
* Create a DataAdapter object (e.g. a SqlDataAdapter instance if you're
using SQL Server), passing your command object and connection object as
parameters.
* Create a DataSet object
* Call Fill() on your DataAdapter object, passing in your DataSet object as
a parameter.

Your DataSet object now contains your results, which you can access in the
normal way.

HTH
Peter

"Robert Bravery" <da****@amataz.co.zawrote in message
news:O1**************@TK2MSFTNGP03.phx.gbl...
HI all,

I'm relatively new to this.
How can I get the results of a SP (returns a recordset) into a dataset

Thanks
Robert


Dec 7 '06 #2
Thanks
Robert

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:ea**************@TK2MSFTNGP05.phx.gbl...
It's a while since I did this, but as I recall, the steps are:

* Create your stored procedure
* Instantiate a command object (e.g. a sqlCommand instance if you're
using
SQL Server)
* Assign your stored procedure's name to the command object's CommandText
property
* Set the command object's CommandType to
System.Data.CommandType.StoredProcedure
* Create a connection object
* Assign the connection object to the command's Connection property
* Create any parameter objects you might need and assign them to the
command's Parameters collection using .Add
* Create a DataAdapter object (e.g. a SqlDataAdapter instance if you're
using SQL Server), passing your command object and connection object as
parameters.
* Create a DataSet object
* Call Fill() on your DataAdapter object, passing in your DataSet object
as
a parameter.

Your DataSet object now contains your results, which you can access in the
normal way.

HTH
Peter

"Robert Bravery" <da****@amataz.co.zawrote in message
news:O1**************@TK2MSFTNGP03.phx.gbl...
HI all,

I'm relatively new to this.
How can I get the results of a SP (returns a recordset) into a dataset

Thanks
Robert


Dec 7 '06 #3

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

Similar topics

2
by: Daniel | last post by:
hi ng, i am newbie to sqlserver and my problem seems simple, but i didn't find information about it: How can i display the RETURN @x value of a stored procedure in the sql analyzer of the...
5
by: Rhino | last post by:
This question relates to DB2 Version 6 on OS/390. Can a (COBOL) stored procedure on this platform do file I/O, i.e. write to a sequential file? I am trying to debug a stored procedure. As far...
2
by: Rod | last post by:
We've got an old VB6 application we wrote years ago, that we're working on converting parts of, to an ASP.NET application. So far, the work is going well. Now I'm looking at trying to convert...
7
by: Peter D.C. | last post by:
Hi I want to update data hold in several textbox controls on an asp.net form. But it seems like it is the old textbox values that is "re-updates" through a stored procedure who updates a SQL...
2
by: Sandy | last post by:
Hello - I am used to retrieving data with stored procedures. DataSets have me baffled inasmuch as it exposes Sql statements directly in the code, however, I think I need to be working with...
7
by: TJoker .NET | last post by:
I'm developing an VB.NET Windows Forms application that uses CR for VS.NET (original version shipped with VS.NET 2002 - my VS.NET has the latest SP installed, no SPs for CR). My reports get their...
1
by: Demetri | last post by:
I have a question / concern regarding the new suggested way of creating a data access layer in an n-tier application. Typically, a web application specifically, using the SOA (Service Oriented...
7
by: Ryan | last post by:
Quite awile ago I posted to this newsgroup in regards to using Datasets in my VB 2005 application. About how many Datasets should be used.. a limit to the number of tables that should be included...
6
by: yin_n_yang74 | last post by:
I am trying to create a report in Crystal Reports (v 8.5). I have a stored procedure to pull data from two databases and parameters. There are multiple one-to-many relationships and the stored...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.