Run a SQL Stored Procedure in Access passing no variables

  • Thread starter Thread starter John
  • Start date Start date
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
 
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
 
Back
Top