Programming :  Student Freelance Forum For Work Experience Builders' (CertificationPoint) The fastest message board... ever.
 
CLASSIC ASP-Execute a Stored Procedure Without an Explicit ADO Command Object
Posted by: adcertpoint (Moderator)
Date: April 29, 2020 04:45PM

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"winking smiley
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 />"winking smiley
MyRecordset.MoveNext()
Loop
Else
Response.Write("No Records Found"winking smiley
End If
%>

Options: ReplyQuote


Sorry, only registered users may post in this forum.
This forum powered by Phorum.