by Muhammad Atif Tahir (1 Submission)
Category: Active Server Pages
Compatability: ASP (Active Server Pages)
Difficulty: Unknown Difficulty
Originally Published: Thu 20th May 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
How to call a stored procedure from active server pages
<% option explicit%>
<!-- #include virtual="adovbs.inc"-->
'Open the Connection
set conn = Server.CreateObject("ADODB.Connection")
conn.open "dsn=dsn;uid=username;pwd=password"
'Now call the stored Procedure
Set cmd=Server.CreateObject("ADODB.Command")
set cmd.activeconnection=conn
cmd.commandtext="Procedure_name"
cmd.commandtype=adcmdStoredProc
cmd.parameters.refresh
cmd.parameters(1).value = Value1
cmd.parameters(2).value = Value2
.
.
cmd.parameters(n).value = Valuen
'for the ouput from stored procdure
cmd.execute
returnvalue = cmd.parameters(0).value
' and for resultset
set rs = cmd.execute.
conn.close