ADO Recordset and Stored Procedures

ADO Recordset and Stored Procedures

Here's how to run a stored procedure with parameters to create a recordset in classic ASP and ADO.
Just make sure that you've included the proper reference in your global.asa in order to use ADO constants. Here's a link with the proper META tags:

http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=202

Set oCon = Server.CreateObject("ADODB.Connection")
Set oRS = Server.CreateObject("ADODB.RecordSet")

sSPString = "myproc('" & sVarcharVariable & "'," & IntegerVariable & ")"

oCon.Open "your connection string goes here"

oRS.Open sSPString, oCon ,adOpenStatic, adLockReadOnly,adCmdStoredProc

If oRS.STATE = adStateOpen Then oRS.Close
If oCon.STATE = adStateOpen Then oCon.Close

Set oRS = Nothing
Set oCon = Nothing


Submission Date:  2/1/2003 10:13:54 PM
Submitted By:  Robbe Morris
My Home Page:  http://www.robbemorris.com

By Robbe Morris   Popularity  (613 Views)
Picture
Biography - Robbe Morris
Robbe has been a Microsoft MVP in C# since 2004. He is also the co-founder of NullSkull.com which provides .NET articles, book reviews, software reviews, and software download and purchase advice.  Robbe also loves to scuba dive and go deep sea fishing in the Florida Keys or off the coast of Daytona Beach. Microsoft MVP