Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CRecordSet and SQL after CRecordSet open

Posted on 1998-08-26
1
Medium Priority
?
532 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
rlarner earned 90 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

636 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