Solved

DAO to call MSAccess parameterized Query

Posted on 1998-10-03
3
233 Views
Last Modified: 2013-11-20
How to use DAO (CDaoRecordset) to call a parameterized query in MS Access?  Can this be done?  CDaoRecordset doesn't seem to work on predifined queries in Access, only on whole tables.  Have previously coded the whole application using ODBC and CRecordset.  This works but its really slow.  Much of the application business logic is stored in Queries in an Access database.  Can these queries be used in CDaoRecorset.  I tried using CDaoQueryDef to open the daorecordset with but not having much luck.  This should be as easy as it was using CRecordset!  
Any Ideas?
Thanks, Jon
0
Comment
Question by:jonjon
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
VAM345 earned 200 total points
ID: 1322903
Hi I using query in may program.
To use CDaoRecordset to call parameterized query in MS Access do this:

CDaoQueryDef myQueryDef(m_pMyDatabase);
CDaoRecordset myRecordset(m_pMyDatabase);
myQueryDef.Open(myQueryName); // Query name in Access.
myQueryDef.SetParamValue(strParamName1, COleVARIANT(strParamValue1));                                    
myQueryDef.SetParamValue(strParamName2, COleVARIANT(strParamValue2));                                    
. for all you parameters
myRecordset.Open(&myQueryDef, dbOpenDynaset);

Use you recordest.

myRecordset.Close();
myQueryDef.Close();

0
 

Author Comment

by:jonjon
ID: 1322904
Beautiful!  That worked great. Thanks.
0
 
LVL 1

Expert Comment

by:VAM345
ID: 1322905
I glad to help you.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question