?
Solved

Query problems

Posted on 1998-09-09
1
Medium Priority
?
194 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
[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
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

718 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