Solved

CRecordSet and SQL after CRecordSet open

Posted on 1998-08-26
1
518 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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now