Returning Stored Proc ReturnValue in ADO
pg.242w_at_gmail.com
Date: 01/14/05
- Next message: Michael Satterwhite: "JRO / Compact database"
- Previous message: Ralph: "Re: Data Access Problem"
- Messages sorted by: [ date ] [ thread ]
Date: 14 Jan 2005 09:00:54 -0800
I am trying to return a ReturnValue from a SQL Server 2000 stored proc
from an ASP page using the ADO Command and Parameter objects.
I have a stored proc that accepts 3 parameters and its basically doing
a select statement based on these input parameters...
At the end of the proc, i am returning the rowcount...@@RowCount to the
ASP page.
ALTER PROCEDURE S_ClientsReturn_Client
( @chrRegisteredStatus varchar(01)= 'A' ,
@inyClientOwner TinyInt = NULL,
@chvSearchValue varchar(77) = NULL,
@chvSearchType Varchar(08) = NULL,
@inyTypeID TinyInt = 0)
AS
DECLARE @intRows INT
.........
Inside the proc,
I have a few conditions that will do select statements...
select XX,
XXXX
from YYYY
SET @intRows = @@RowCount
At the end...
RETURN @intRows
The procedure only returns one set of select results...
On the ASP side:
Dim m_oConn, m_oRS, m_lRecs, m_iIndex, m_oCmd, m_oParam
Const MAX_RECS = 10
Set m_oConn = Server.CreateObject("ADODB.Connection")
With m_oConn
.ConnectionString = DSN
.CursorLocation = adUseClient
.Open
End With 'm_oConn
Set m_oCmd = Server.CreateObject("ADODB.Command")
With m_oCmd
.ActiveConnection = m_oConn
.CommandText = "S_ClientsReturn_Client"
.CommandType = adCmdStoredProc
.NamedParameters = True
' Create and add 1st param to command
Set m_oParam = .CreateParameter
With m_oParam
.Direction = adParamInput
.Name = "@chrRegisteredStatus"
.Size = 1
.Type = adChar
.Value = "R"
End With 'm_oParam
.Parameters.Append m_oParam
' Create and add 2nd param to command
Set m_oParam = .CreateParameter
With m_oParam
.Direction = adParamInput
.Name = "@inyClientOwner"
.Type = adTinyInt
.Value = 1
End With 'm_oParam
.Parameters.Append m_oParam
' Create and add param for ReturnValue to command
Set m_oParam = .CreateParameter
With m_oParam
.Direction = adParamReturnValue
.Name = "@intRows"
.Type = adInteger
End With 'm_oParam
.Parameters.Append m_oParam
Set m_oRS = .Execute
' Display number of rows
Response.Write("<BR>Number Of Rows: " & .Parameters("@intRows").Value
& "<BR>")
End With 'm_oCmd
The preceding code returns the following error:
Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
@intRows is not a parameter for procedure S_ClientsReturn_Client.
How can I access the ReturnValue (@@RowCount) through ASP code?
Thanks
- Next message: Michael Satterwhite: "JRO / Compact database"
- Previous message: Ralph: "Re: Data Access Problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|