CDaoQuerydef and CDaoRecordset; running a query help
Posted on 1998-08-26
I'm trying to do a simple search through my database. I created a query in Access called "Simple Search". The Criteria is: [Title] like [Search String]. Title is a field in the database. Search String is a parameter that is set by my program. This is my code:
//m_pDaoWorkspace and m_pDaoDatabase have already been created
int isRet = q.GetReturnsRecords(); // this returns 1
int param = q.GetParameterCount(); // this returns 1
q.GetParameterInfo(0,info); // the 1 param = Search String
//I hope I have done this right.This might explain problem
CMyRecordset *r; // derived from CDaoRecordset
r = new CMyRecordset( m_pDaoDatabase );
if( ! r->IsOpen( ))
catch( CDaoException* eDaoException )
int recs = r->GetRecordCount();
This last line is the problem. it returns 0.
If I do not pass the CQueryDef pointer to the Open function of CMyRecordset and just open it as a normal dynset recordset GetRecordCount returns 220 as it should. There are 220 records in the database. So the problem lies in my CQueryDef usage and most likely, I figure how I set the parameter. Because if I run the query in MS-Access with the same value as I set it in my program it returns some 50 records.
I'd really appreciate any information I could get about things to look at.