or you can try the following
DET.m_strSTKParam="%";
DET.m_strDOCNParam=m_getdo
DET.m_strFilter="STK LIKE ? AND DOCN= ?";
not sure but maybe ..
Main Topics
Browse All TopicsI have 2 indexes STKI and DOCI. I need to Filter for the 2nd index only,ie all records with DOCN (2nd param) regardless of the STK (1st param). What do I substitute for the m_strSTKParam. I have tried inserting ALL and
*, and other combinations. MSDN Documentation does not address this specifically. If I only put the second parameter in the strFilter and not the rest it also doesn't work because the recordset has 2 parameters so the strFilter is supposed to have both Parameters. The question is what do I put for the 1st parameter?
DET.m_strSTKParam="";
DET.m_strDOCNParam=m_getdo
DET.m_strFilter="STK= ? AND DOCN= ?";
DET.Requery();
(If I I specify a value for the 1st and 2nd Param then there is no problem so that is not the question.)
Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The answer to this question is quite simple. When the first param is empty, the resulting WHERE clause is invalid. The SQL Server will see something like:
SELECT * FROM MyTable WHERE STK= AND DOCN= 'someValue'
which is obviously an error. The simple and intiutive solution is to not use the STK=? parm when you don't want to use STK in the search criteria!
But there is another workaround if you can't figure out how to do that. Use
SELECT * FROM MyTable WHERE STK=STK AND DOCN= 'someValue'
I see no way to do that with query parameters, because the driver will treat it like a quoted string. But parameters are just a pain to work with anyway. Just get rid of the parameterss altogetherand format the m_strFilter string as desired:
if ( m_getStk != "" ) {
DET.m_strFilter.Format( "STK= '%s' AND DOCN= '%s'", m_getStk, m_getdoc );
}
else {
DET.m_strFilter.Format( "DOCN= '%s'", m_getdoc );
// alternative, foolish but functional
// DET.m_strFilter.Format( "STK=STK AND DOCN= '%s'", m_getdoc );
//
}
-- Dan
Business Accounts
Answer for Membership
by: zfactPosted on 2003-02-26 at 22:43:13ID: 8031517
Hi binstar,
c;
Try doing this.
if you want only the sencond parametsr, then set the filter only for the second parameter like below, it will work.
DET.m_strSTKParam="";
DET.m_strDOCNParam=m_getdo
DET.m_strFilter="DOCN= " + m_getdoc;
DET.Requery();
Try it, All the best.
Zfact