Solved

Query problems

Posted on 1998-09-09
1
187 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 70 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

17 Experts available now in Live!

Get 1:1 Help Now