I am getting the following error when I call my WV_GetUserData function passing in a userid that does not exist in the database; however, when the userid is valid, I get the correct response.
I hope someone can help me trap this issue that I have. If there is a better way to write the code that I have, please advise. Thank you.
Error:
Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
/trading/brian/getUserId.asp, line 9
function WV_GetUserData(userid)
dim cmd, rs
'create ado objects
Set cmd = Server.CreateObject("ADODB.Command"
Set rs = Server.CreateObject("ADODB.Recordset"
with cmd
' set up a command object properties
.ActiveConnection = GetConnection()
.CommandText = "WVGetUserData"
.CommandType = adCmdStoredProc
'create parameters for stored procedure call
.Parameters.Append .CreateParameter("@userid",adInteger,adParamInput)
'assign values to parameters
.Parameters("@userid"
= userid
'execute the command object
Set rs = .Execute
end with
'return recordset object into function name
Set WV_GetUserData = rs
'de-initialize the command object
Set cmd = Nothing
end function
<%
set rs = WV_GetUserData(900)
if rs.RecordCount = 0 then
Response.Write("No user"
else
do while not rs.EOF
Response.Write(rs("username"
& "<br>"
rs.movenext
Loop
end if
set rs = nothing
%> regards,
Brian
I hope someone can help me trap this issue that I have. If there is a better way to write the code that I have, please advise. Thank you.
Error:
Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
/trading/brian/getUserId.asp, line 9
function WV_GetUserData(userid)
dim cmd, rs
'create ado objects
Set cmd = Server.CreateObject("ADODB.Command"
Set rs = Server.CreateObject("ADODB.Recordset"
with cmd
' set up a command object properties
.ActiveConnection = GetConnection()
.CommandText = "WVGetUserData"
.CommandType = adCmdStoredProc
'create parameters for stored procedure call
.Parameters.Append .CreateParameter("@userid",adInteger,adParamInput)
'assign values to parameters
.Parameters("@userid"
'execute the command object
Set rs = .Execute
end with
'return recordset object into function name
Set WV_GetUserData = rs
'de-initialize the command object
Set cmd = Nothing
end function
<%
set rs = WV_GetUserData(900)
if rs.RecordCount = 0 then
Response.Write("No user"
else
do while not rs.EOF
Response.Write(rs("username"
rs.movenext
Loop
end if
set rs = nothing
%> regards,
Brian