Stored Procedure has both return value and data set (SqlDataReader)

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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. ...
    3. 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...
    4. 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...
    5. 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....
  3. #2

    Default 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...
    > 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
    >
    >
    >

    CT Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139