This is how I am currently getting the user name based on a user id. I am calling a stored procedure within this function, but when I call this function from another asp page, how should I be calling it. If the id does not exist in the database my browser starts hanging and I get a 100% CPU utilization. Does anyone else have an example similar to what I am trying to do here? Thanks.
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
<%
on error resume next
set rs = WV_GetUserData(900)
if rs.BOF and rs.EOF then
Response.Write("No user"
else
do while not rs.EOF
Response.Write(rs("username"
& "<br>"
rs.movenext
Loop
end if
set rs = nothing
on error goto 0
%> regards,
Brian
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
<%
on error resume next
set rs = WV_GetUserData(900)
if rs.BOF and rs.EOF then
Response.Write("No user"
else
do while not rs.EOF
Response.Write(rs("username"
rs.movenext
Loop
end if
set rs = nothing
on error goto 0
%> regards,
Brian