Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DAO to call MSAccess parameterized Query

Posted on 1998-10-03
3
Medium Priority
?
246 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 800 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

927 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