Solved

DAO to call MSAccess parameterized Query

Posted on 1998-10-03
3
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: 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

Suggested Solutions

Title # Comments Views Activity
set up trigger (or something) to rename files (starting with ATL) in a linux directory 6 56
countEvens challenge 2 113
noX challenge 17 134
unix example issues 18 106
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

740 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