DAO - executing stored procedures 
Author Message
 DAO - executing stored procedures

I know DAO is old hat, but I'm sure this can be done. I need to execute
a recordset returning parameterized stored procedure...how do you define
the parameters? I haven't found any good examples from VB help. This
code snippet assumes an ODBC direct connection object has already been
established.

Dim qdf as QueryDef
Dim rs as Recordset
'  "con" is a Connection: ODBC direct - already established

Set qdf = con.CreateQueryDef("")
qdf.SQL = "{ call my_stored_proc (?) }"
Set rs = qdf.OpenRecordset()

The parameter definition is missing...where does it go and what's the
syntax?

Ted



Sun, 17 Mar 2002 03:00:00 GMT  
 DAO - executing stored procedures
Ted,

I think this is what you are looking for.  I assume that CALDB has been
connected to an Access database.

Dim CALDB As Database
Dim CALRS As Recordset
Dim CALQUERY As QueryDef

'specify the query (already stored in the database)
Set CALQUERY = CALDB.QueryDefs("SelectRecord")
'initialize the parameters
CALQUERY.Parameters("EnterSN") = CLng(strSN)
CALQUERY.Parameters("EnterMO") = strMONum
CALQUERY.Parameters("EnterRN") = strRNum
'execute the query and assign the result
Set CALRS = CALQUERY.OpenRecordset(iType)

Joe

Quote:

>I know DAO is old hat, but I'm sure this can be done. I need to execute
>a recordset returning parameterized stored procedure...how do you define
>the parameters? I haven't found any good examples from VB help. This
>code snippet assumes an ODBC direct connection object has already been
>established.

>Dim qdf as QueryDef
>Dim rs as Recordset
>'  "con" is a Connection: ODBC direct - already established

>Set qdf = con.CreateQueryDef("")
>qdf.SQL = "{ call my_stored_proc (?) }"
>Set rs = qdf.OpenRecordset()

>The parameter definition is missing...where does it go and what's the
>syntax?

>Ted



Mon, 18 Mar 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. DAO - executing stored procedures

2. How to execute stored procedure by DAO of VB5.0

3. Execute a SS7 stored procedure

4. executing an extended stored procedure on SQLServer from VBA

5. Access executing stored procedures

6. Executing an oracle stored procedure from access 95

7. problem executing a stored procedure

8. Executing to SQL Stored Procedure with parameters

9. How to call and execute system stored procedures?

10. error while executing store procedure command

11. How to execute a Stored Procedure using ADO.Net

12. Executing SQL Server Stored Procedure from VB

 

 
Powered by phpBB® Forum Software