Solved

CRecordSet and SQL after CRecordSet open

Posted on 1998-08-26
1
523 Views
Last Modified: 2013-11-19
Is it possible to make another SQL query AFTER the CRecordset open statement.
I know that it is possible to use the  
m_strFilter (to add a where statment) and the m_strSort
(for a ORDER BY statement). Then by calling the requery, the CRecordset instance will be updated accordingly.
     But if you want to carry out a Select Count(*) followed by a Select <Column>, is this possible to do  this with out closing and reopening the Crecordset instance with the appropriate query string and to not use any API functions.
 
0
Comment
Question by:martythegreat
1 Comment
 
LVL 1

Accepted Solution

by:
rlarner earned 30 total points
ID: 1321287
Simple answer: No.  Changing the select statment is a fairly major change to the query, and would require _at least_ a 'requery' call.  You can simulate the select count by opening the recordset to the select <column> query, doing a move first, and then moveNext while incrementing a counter until you hit the end of the table.  This is actually faster than it sounds on most (< 100,000 records) db's on most systems.
However -- you may want to look into the CDao* (e.g. CDaoRecordset) classes.  They usually have all the functionality that the ODBC classes have, plus more.  If you are working with an Access database, they are definately the way to go.  The CDaoRecordset has a working count function, so you can just select <column>, move to the last record, and get the record count, thus removing the need for your first query.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 134
ffmpeg - "rtsp://...... Operation not permitted" 4 89
building a service to accessed via telnet client, want colors ? 4 98
Message not shown 5 87
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.

726 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