Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedure call best practices

Status
Not open for further replies.

BG12424

Programmer
Jun 4, 2002
717
US
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(&quot;No user&quot;)
else
do while not rs.EOF
Response.Write(rs(&quot;username&quot;) & &quot;<br>&quot;)
rs.movenext
Loop
end if

set rs = nothing

on error goto 0

%> regards,
Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top