The following code shows you how to execute a Stored Procedure (called MyStoredProcedure) in ASP without creating an explicit ADO Command object. The Stored Procedure expects two parameters: @FirstParam (of datatype int) and @SecondParam (of datatype varchar). Modify the parameter list to suit your requirements
The Stored Procedure should look similar to this:
CREATE PROCEDURE MyStoredProcedure
@FirstParam int,
@SecondParam varchar(10)
AS
Your SELECT statement here
And the code in ASP page should look like this:
<%
Dim MySQLStatement
Dim MyConnection
Dim MyRecordset
Dim intValue
Dim stringValue
intValue = 10
stringValue = "Test Value"
MySQLStatement = "exec MyStoredProcedure @FirstParam=" & intValue & _
", @SecondParam='" & stringValue & "'"
Set MyConnection = Server.CreateObject("ADODB.Connection"
MyConnection.Open MyConnectionString
Set MyRecordset = MyConnection.Execute(MySQLStatement)
If Not MyRecordset.EOF Then
Do While Not MyRecordset.EOF
Response.Write("Record " & MyRecordset.Fields(0).Value & " - " _
& MyRecordset.Fields(2).Value & "<br />"
MyRecordset.MoveNext()
Loop
Else
Response.Write("No Records Found"
End If
%>