Solved

Query problems

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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