FIX: DBF() & RECCOUNT() Return Wrong Info About SQL Cursor

Last reviewed: October 20, 1997
Article ID: Q117265
2.5x 2.6x | 2.5x 2.6x
WINDOWS   | MS-DOS
kbprg kbfixlist kbbuglist

The information in this article applies to:

  • Microsoft FoxPro for Windows, versions 2.5x, 2.6x
  • Microsoft FoxPro for MS-DOS, versions 2.5x, 2.6x

SYMPTOMS

Using the RECCOUNT() or DBF() functions against a cursor returns information pertinent to the source data file instead of the currently selected cursor.

CAUSE

If a WHERE clause is used that references a field that is used as a key field in a .CDX index tag, the DBF() and RECCOUNT() functions will return data about the source data file instead of the cursor. This is because, in this case, the SQL-SELECT performs a SET FILTER on the current table, and returns the filtered information. Use the _TALLY variable to return the number of records processed by the SQL-SELECT command.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual FoxPro 3.0 for Windows.

MORE INFORMATION

This behavior will occur regardless of the status of the SET ORDER command. However, this behavior does NOT occur under Microsoft Windows NT.

Steps to Reproduce Problem

In the steps below, you will be using the CUSTOMER database (which contains 500 records) in the TUTORIAL subdirectory. Make certain that the .CDX file is active, and that it includes a tag built on CNO.

  1. In the Command window, issue the following commands:

          CLEAR ALL
          USE <FoxPro_directory>\tutorial\customer.dbf
          SELECT * FROM customer WHERE customer.cno = 'A'
    

    Note that 29 records are selected.

  2. In the Command window, issue the following command:

          ? DBF()
    

    Note that it returns the name of the source file, not the temporary cursor name.

  3. In the Command window, issue the following command:

          ? RECCOUNT()
    

Note that the RECCOUNT() of the source file, not the cursor, is returned. Note also that the status bar shows 500 records in the cursor even though the SELECT command reported that only 29 records were selected.

For comparison, do the following:

  1. In the Command window, issue the following command:

          CLEAR ALL
    

  2. Remove the tag on the CNO field.

  3. Repeat steps 1-3 above, but change the SELECT statement to:

          SELECT * FROM customer WHERE customer.cno = 'A'
    

Note that the SELECT statement returns 29 records, ? DBF() returns the name of the temporary file (cursor), and ? RECCOUNT() returns 29.


Additional reference words: VFoxWin fixlist3.00 FoxDos FoxWin 2.50 2.50a
2.50b 2.60 2.60a buglist2.50 buglist2.50a buglist2.50b buglist2.60
buglist2.60a
KBCategory: kbprg kbbuglist
KBSubcategory: FxprgGeneral
Keywords : FxprgGeneral kbbuglist kbprg
Version : 2.5x 2.6x | 2.5x 2.6x
Platform : MS-DOS WINDOWS
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 20, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.