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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
HanookPosted Nov 21, 2013, 6:22 AM
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
Jaganathan BantheswaranPosted Nov 21, 2013, 6:12 AM
Jaganathan BantheswaranPosted Nov 20, 2013, 1:03 AM
<%
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