Solved

DAO to call MSAccess parameterized Query

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Process filename extension 3 156
sumDigits challenge 9 98
no14 challenge 14 57
either24  challenge 19 84
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…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now