SP.... result se and output parameter....

H

Hewit

I have a stored procedure which returns records and output
parameters(SQL2K). How to call this stored procedure using ADO.Net so
that
I can use both results in my application. I have .Net Framework 1.1.
when I use ExecuteReader() of Command object I cannot read the output
parametrs of the stored procedure in code.
Please advice.
Hewit
 
M

Mona

Hi Hewit,

To read the output parameter of the stored procedure,
you first need to specify the direction of the parameter.

Following is the ADO.NET code snippet to use stored procedure
to return output parameters

Dim cnn As SqlConnection = New SqlConnection(myconn)
Dim cmd As SqlCommand = New SqlCommand("sp_Getparam",cnn)
cmd.CommandType = CommandType.StoredProcedure
Dim parm as SqlParameter = cmd.Parameters.Add("@Output", SqlDbType.Int)
parm.Direction = ParameterDirection.Output
cnn.Open()

To retrieve the output parameter you an use the following syntax

cmd.Parameters("@Output").Value

As for the records, you can use the data reader to retrieve it.

HTH

Mona
 
W

William \(Bill\) Vaughn

See my article on handling OUTPUT parameters.
http://www.betav.com/msdn_magazine.htm

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top