What is the best way to run stored procedure from the MS Access

accesser2003

Registered User.
Local time
Tomorrow, 00:14
Joined
Jun 2, 2007
Messages
124
I created a stored procedure in my SQL Server backend. What is the simplest way I can use to run it from the MS Access code and pass its parameters.

Is there is a way similar to what we do with the backend tables where we add them to our Database window by make a link to those in the backend and then deal with them as normal ADO tables. I mean what is the simplest way to run a stored procedure from the MS Access Code and pass its parameters similar to what we do when we run the parameterized quries as

set myproc=currentdb.querydef("myproc")
myproce.parameters('p1')=p1
myproce.execute


My varibles are as follow:

ODBC
ServerName: AMD\BAHRAIN
DSN: BAHRAIN
Database: BAHRAIN
Trusted_Connection="Yes"
Windows NT Authectication
Stored Procedure Name: myproce , parameters: @p1
 
While I've never actually used sp just yet, I'm pretty sure to use them you would have to use a pass through query. Create one, then set some of properties (e.g. don't return recordsets if it's not to supposed to expect one and so forth) then type in the SQL that you would normally type when interacting with the server.

Something like CALL myproc WITH @p1.
 
I need a written code example
 
You can use that code you just gave as an example in OP. My point was that you need to create a actual query in database windows first, make it a pass through (by right-ciicking on gray area and selecting SQL-Specific -> Pass through), then type in the command you use to execute the sp as if you were at SQL server, then in query's property window, enter the connection string, whether it's supposed to return records or not etc.

All of this is done in GUI up to this point. Once you've created and saved the query, you can use that exact code you just showed to run that query.
 

Users who are viewing this thread

Back
Top Bottom