Parameterized query using CRecordset 
Author Message
 Parameterized query using CRecordset

Problem-

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.

Daljeet



Mon, 28 Jan 2002 03:00:00 GMT  
 Parameterized query using CRecordset
Why not just just use the inherited member m_strfilter of CRecordSet for the
query and then the requery should work fine.

Steve

Quote:

>Problem-

>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.

>Daljeet



Mon, 28 Jan 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. CRecordset, Oracle7.3 and parameterized queries

2. CRecordset - parameterized predefined queries/stored procedures

3. Crecordset: parameterized access to pre-defined queries

4. Dynamically Creating parameterized queries using VC++

5. Dynamically Creating parameterized queries using VC++

6. Dynamically Creating parameterized queries using VC++

7. Using * In Parameterized Query?

8. Query hangs using CRecordset::Open()

9. Query hangs using CRecordset::Open()

10. parameterized Management Query String

11. ADO Parameterized Queries

12. Parameterized SQL query failing

 

 
Powered by phpBB® Forum Software