How to call sql server store procedure in classic asp
I have sql srver store procedure which accept 10 parameters as input. How to call this store procedure in classic asp and pass a parameter values to it in classic asp?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Nov 19, 2013, 8:03 PM EST
<%
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "data source name", "userid", "password"
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = cn
' Define the stored procedure's inputs and outputs
' Question marks act as placeholders for each parameter for the
' stored procedure
cmd.CommandText = "{?=call sp_test(?)}"
' specify parameter info 1 by 1 in the order of the question marks
' specified when we defined the stored procedure
cmd.Parameters.Append cmd.CreateParameter("RetVal", adInteger, _
adParamReturnValue)
cmd.Parameters.Append cmd.CreateParameter("Param1", adInteger, _
adParamInput)
cmd.Parameters("Param1") = 33
cmd.Execute
%>
Calling via method 3
ReturnValue = <% Response.Write cmd("RetVal") %>
Source: MSDN
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Nov 21, 2013, 1:12 AM EST
Hanook159 reputationPosted Nov 21, 2013, 1:22 AM EST
Simple steps to call stored procedure in ASP
set con = Server.CreateObject("ADODB.Connection")
con.Open strConnect
Set Comm = Server.CreateObject("ADODB.Command")
comm.ActiveConnection = con
comm.CommandText = "sqlstoredprocedurename"
comm.CommandType = adCmdStoredProc
comm.Parameters.Append comm.CreateParameter("ID" , adVarchar,adParamInput, 50, id)
comm.Parameters.Append comm.CreateParameter("PRODUCT", adVarchar, adParamInput,50, producttype )
comm.Parameters.Append comm.CreateParameter("ACCOUNT", adVarchar, adParamInput,100, "" )
comm.Parameters.Append comm.CreateParameter("O_Errors", adVarchar, adParamOutput,50) 'output parameters
comm.Execute
References:
http://stackoverflow.com/questions/15092616/sql-server-stored-procedure-for-asp-classic