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

x
?
Solved

Query problems

Posted on 1998-09-09
1
Medium Priority
?
198 Views
Last Modified: 2013-11-20
Hi!!
I'm working with DAO and an ACCESS dbase, where
is defined a querry ("Identify ID") with one parameter
([IDTEST]).
  If I create and open a CDaoQueryDef object for this query and set the parameter everything is fine.
The GetReturnsRecords( ) method return TRUE.
But when I open a recordset with this CDaoQueryDef object as parameter, there are no records in the recorset.
I have tried this with a CDaoRecorset derived class (with Class Wizard). Nothing. If I remove query's parameter (so the querry have not parameter), it's O.K.
The query has been made in Access.
What is tehe problem?
This is the source:

CDaoQueryDef tempQuery(&m_pDoc->m_TheDBase);
tempQuery.Open("IdentifyID");
CDaoRecordset qd(&m_pDoc->m_TheDBase);;
COleVariant varParamValue( (LPCSTR) m_Identity );
tempQuery.SetParamValue( "[IDTEST]", varParamValue );
BOOL b= tempQuery.GetReturnsRecords( );
qd.Open(&tempQuery, dbOpenDynaset );
if(qd.IsEOF()) return CString("No user with this ID!!");
 
//the [IDTEST] type is Text
0
Comment
Question by:visualc
1 Comment
 
LVL 1

Accepted Solution

by:
Bonev earned 140 total points
ID: 1321921
The problem is not in your program, but in the COleVariant class.
You should create COleVariant from LPCSTR, using this code:

COleVariant varParamValue((LPCSTR)m_Identity, VT_BSTRT);

btw, if m_Identity is CString, you don't need the conversion -
COleVariant varParamValue(m_Identity, VT_BSTRT);


0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

971 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