
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