Solved

DAO to call MSAccess parameterized Query

Posted on 1998-10-03
3
235 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
cat dog challenge 18 127
Complete beginner needs help making a cron job 9 125
List out all word 7 317
wait notify demo infinite loop 3 124
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

839 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