Run a SQL Stored Procedure in Access passing no variables

J

John

Does anyone have some code on how to execute a Stored
Procedure in SQL that does not need to be passed any
parameters.

Thanks,
John
 
R

Ron Weiner

if it returns records, Something like:
Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection

Set cn = New ADODB.Connection
cn.ConnectionString = strCon ' strCon is a Valid Connection string to
your Database
cn.Open
Set rs = cn.Execute("NameOfYourSP")
' Do stuff with the Recordert
rs.Close
cn.Close
set rs = Nothing
set cn = Nothing

else if it dosent return any records

Dim cn As ADODB.Connection

Set cn = New ADODB.Connection
cn.ConnectionString = strCon ' strCon is a Valid Connection string to
your Database
cn.Open
cn.Execute("NameOfYourSP")
cn.Close
set cn = Nothing

Ron W
 
Top