You need to create a Command object (SqlCommand) and create a Parameters
collection. The RETURN value is passed back as the first parameter. I'm not
going to write a C# example for you (I'm not into that kind of abuse), but
this VB.NET example should help. It's featured in a new article to be
(eventually) published in MSDN magazine.
Dim bolEOF As Boolean
cn = New SqlConnection("server=demoserver;database=biblio;integrated
Dim cmd As New SqlCommand("OutputTitleByISBNandType", cn)
cmd.CommandType = CommandType.StoredProcedure
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
' process rowset(s)
bolEOF = dr.Read
Do While bolEOF = True
' Process rows
bolEOF = dr.Read()
Loop While dr.NextResult = True
Catch ex As Exception
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
> Hi. Can someone tell me how to get the return value from a stored
> proc. using ado.net? I have the following c# code:
> int test = (int)(com.ExecuteScalar());
> My stored proc is:
> CREATE PROCEDURE xxxx
> -- add rec
> I know that i could use a select and get the id back that way but I
> cannot change the procedure so I need to be able to get the result
> back from the RETURN. Thanks very much for any help.