Click here to Skip to main content
15,509,913 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
parameterized Query Using CRecordset


I have a CRecordset derived class say CRecord which is binded to all the columns of one table say table1.

Now I want to query that table with two parameters(using ? ) and for that I have done the following things-

1. Two variables declared in CRecord class.
2. Given m_nParams=2; in CRecord constructor.
3. In DoFieldExchange included the SetFieldType() and RFx_*() for both the parameters in the sequence in which they are to be used in parameterized query.
3. Initialized the two parameters before opening the recorset.
4. called Open() function with CRecord object passing parameterized query.
It works fine.
Say in second case Using the same CRecord class object I want to Requery in which I use only one parameter instead of two.
Now in this case the DoFieldExchange() function which is having two RFX_* for two parameters for earlier query gives error at runtime.
Please tell me how I can use the same CRecordset class for queries having variable number of parameters.
Thanks in advance.

What I have tried:

I did some google searching I found this QueryDef - a complete implementation of a dynamic recordset[^]
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900