Solved

CRecordSet and SQL after CRecordSet open

Posted on 1998-08-26
1
521 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pressing cancel button with C# UI Automation 3 70
Best tools for Backup and restore of Wordpress site 6 57
if loop in java 3 142
move a line in eclipse 3 104
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.

825 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