Solved

Query problems

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Need to retreive data from .TFS file exported by DVR 8 166
mixString challenge 36 98
Folder Comparison 12 52
sumHeights2  challenge 7 75
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

14 Experts available now in Live!

Get 1:1 Help Now