Ask a Question related to ASP.NET General, Design and Development.
-
Neo Chou #1
Stored Procedure has both return value and data set (SqlDataReader)
Greetings!
I met the same question as in ADO a few months ago.
I'm working on MS SQL Server 2000. I have a stored procedure that returns a
return value as well as a record set (by "select" statement). Below is my
ASP code:
<%
Set OBJdbConn = Server.CreateObject("ADODB.Connection")
....
OBJdbConn.CursorLocation = adUseClient
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = OBJdbCONN
....
Set rs = Server.CreateObject("ADODB.Recordset")
Set rs = cmd.Execute
ResultType = cmd("@ResultType")
If ResultType = 0 Then
Do Until rs.EOF
....
rs.MoveNext
Loop
rs.Close
End If
%>
I can get the return value and record set at the same time, by specifying
"CursorLocation" as "adUseClient". Now I want to re-write it in
ASP.NET/ADO.NET. I'm using SqlConnection, SqlCommand and SqlDataReader. I
can only get the return value after the SqlConnection is closed, but at that
time SqlDataReader is no longer available. Is there any option in
ADO.NET/SqlClient to specify "CursorLocation" as ADO?
Thanks in advance!
Neo
Neo Chou Guest
-
Trouble getting stored procedure return value!?
This is my first stored procedure so go easy on me. Procedure runs fine except I can't get a value into the return value @RecordCount. CREATE... -
Can't get return Value from Stored Procedure
I'm trying to get the @@IDENTITY value back from my stored procedure in T-SQL to use it in later code. I haven't been able to get it to work. ... -
ASP/ADO: Return a value from a Stored Procedure
I generally use the following code to call a stored procedure: sSQL = "Exec MySP " & param1 & ", " & param2 oConn.Execute (sSQL) .... or... -
Using stored procedure to return a whole row of data, without using record set?
I now know that I cannot use client application written in embedded SQL to receive record sets, that only an application using CLI can receive... -
Getting Return Value of Stored Procedure
Hello Friends ! I have the Following Code, that Executes a Stored Procedure and Attempt to read a Returned Integer Value from the StoredProc.... -
CT #2
Re: Stored Procedure has both return value and data set (SqlDataReader)
I'm afraid there isn't a CursorLocation option with ADO.NET. So, what you
can do is to have the return value returned as the first result set,
followed by the data from the SELECT statement, and use the NextResult
method of the DataReader to move from the return value once read, to the
actual result set. If modifying the stored procedure isn't an option you
will need to go with the DataAdapter and DataSet.
--
Carsten Thomsen
Enterprise Development with Visual Studio .NET, UML, and MSF
[url]http://www.apress.com/book/bookDisplay.html?bID=105[/url]
"Neo Chou" <neochou@hotmail.com> wrote in message
news:eMYGUFYWDHA.2544@tk2msftngp13.phx.gbl...a> Greetings!
>
> I met the same question as in ADO a few months ago.
>
> I'm working on MS SQL Server 2000. I have a stored procedure that returnsI> return value as well as a record set (by "select" statement). Below is my
> ASP code:
>
> <%
> Set OBJdbConn = Server.CreateObject("ADODB.Connection")
> ...
> OBJdbConn.CursorLocation = adUseClient
> Set cmd = Server.CreateObject("ADODB.Command")
> Set cmd.ActiveConnection = OBJdbCONN
> ...
> Set rs = Server.CreateObject("ADODB.Recordset")
> Set rs = cmd.Execute
> ResultType = cmd("@ResultType")
> If ResultType = 0 Then
> Do Until rs.EOF
> ...
> rs.MoveNext
> Loop
> rs.Close
> End If
> %>
>
> I can get the return value and record set at the same time, by specifying
> "CursorLocation" as "adUseClient". Now I want to re-write it in
> ASP.NET/ADO.NET. I'm using SqlConnection, SqlCommand and SqlDataReader.that> can only get the return value after the SqlConnection is closed, but at> time SqlDataReader is no longer available. Is there any option in
> ADO.NET/SqlClient to specify "CursorLocation" as ADO?
>
> Thanks in advance!
>
> Neo
>
>
>
CT Guest



Reply With Quote

