Solved

CRecordSet and SQL after CRecordSet open

Posted on 1998-08-26
1
527 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 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

690 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