Return values from a stored procedure.....

Results 1 to 2 of 2

Thread: Return values from a stored procedure.....

  1. #1
    asp_drug_dealer Guest

    Default Return values from a stored procedure.....

    I am having problems with a stored procedure and trying to return values from it. I can get it to return a recordset ok, but I would also like to return a single value along with that recordset. Something like this....<BR><BR>Create procedure sp_crap<BR><BR>@ID int,<BR>@title varchar(30) OUTPUT<BR><BR>AS<BR>SET NOCOUNT ON<BR>--get user title<BR>Select @title = user_title From users where user_id = @int<BR>Select * from user_history where user_id = @int<BR><BR>------------------------------------<BR>Now I try to call it in ASP, I just get a blank for @title<BR>Set strCommand = Server.CreateObject("ADODB.Command")<BR>strCommand .ActiveConnection = connectme<BR>strCommand.CommandText = "sp_crap"<BR>strCommand.CommandType = adCmdStoredProc<BR>strcommand.Parameters.Refresh<B R>strCommand("@ID") = request.form("user_num")<BR>strCommand.CreateParam eter("@title",adVarChar,adParamOutput)<BR>Set RStemp = strCommand.Execute<BR>&#039try to view it..<BR>Response.Write(strCommand("@title"))<BR>&# 039I do not get anything?<BR>&#039The recordset works great.<BR><BR>Any help would be great!<BR>DRUG_DEALER<BR>

  2. #2
    Nathen Grass Guest

    Default RE: Return values from a stored procedure.....

    Try this, this is off the top of my head so I haven&#039t tested it to see if it actually works but it should get you going along the right track:<BR><BR>intID = Request.Form("user_num")<BR>Set objRS = Server.CreateObject("ADODB.Recordset")<BR>Set objCmd = Server.CreateObject("ADODB.Command")<BR>objCmd.Act iveConnection = connectme<BR>objCmd.CommandText = "sp_crap"<BR>objCmd.CommandType = adCmdStoredProc<BR><BR>objCmd.Parameters.Append _<BR>objCmd.CreateParameter("@ID",adInteger,adPara mInput,4,intID)<BR>objCmd.Parameters.Append _<BR>objCmd.CreateParameter("@title",adVarChar,adP aramOutput,64)<BR><BR> cmd,,adOpenForward,adLockReadOnly<BR>outputVal = objCmd.Parameters("@title").value<BR>

Posting Permissions

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