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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top