CRecordset & queries 
Author Message
 CRecordset & queries

 Env: NT 4.0/Win95, MFC, VC++ 5.0 SP2

I have a program here that is searching our company database.  When I get a
lastname string to search on I set the m_strFilter to the string and then
open the database.  From what I understand this should open the database
with whatever records match my query.  This is true, however, when I try to
loop to get all of the matching records, EOF isn't reached until it's
searches all
75000+ records.  I was wondering if there was some way to find out how many
records matched the query so I can break out of this loop.

If this is useful information, the member variables are continually filled
with the
values that are matched by the query so the query appears to be record, but
it's looping through the same 7 records that match the query 75,000 times
(and that's a REAL performance issue).  Any help is appreciated.  Thanks.



Mon, 13 Mar 2000 03:00:00 GMT  
 CRecordset & queries

Hi Bill,

It sounds like your query produced a Cartesian result.  How about a look at
the filter statement.

--
===================
Frank Hickman
SecurTech, Inc.


===================



Mon, 13 Mar 2000 03:00:00 GMT  
 CRecordset & queries

                IngSubCodesTable.Open();

                RecordCount = IngSubCodesTable.GetRecordCount();

                if (RecordCount == 0 || RecordCount == -1)
                {
                        // this is an error
                        return false;
                }
                else
                {
                        // we know there is at least one record in here
                        // need to loop through the records to determine if we have a match
                        IngSubCodesTable.MoveFirst();
                        if (IngSubCodesTable.m_IngramCode == IngSubCat)
                        {
                                // we  found a match; this is a computer book
                                BaseInfoSet->m_f_Computer = true;
                                FoundMatch = true;
                                return true;
                        }
                        while (!IngSubCodesTable.IsEOF() && !FoundMatch)

I do the same thing, and I am able to loop just through my matching records
and break out.  Let's say your Recordset is called "Table."

1)  make sure there are records using the GetRecordCount method for
CRecordset.

2)  if so, move to the first record using MoveFirst and process it

3) then do a while loop for the remaining records in your recordset
        while (!Table.IsEOF())
{
// your logic

Quote:
}

There are probably many ways to do this, but this does not fail for me.

Hope that helps.
Karen



Quote:
>  Env: NT 4.0/Win95, MFC, VC++ 5.0 SP2

> I have a program here that is searching our company database.  When I get
a
> lastname string to search on I set the m_strFilter to the string and then
> open the database.  From what I understand this should open the database
> with whatever records match my query.  This is true, however, when I try
to
> loop to get all of the matching records, EOF isn't reached until it's
> searches all
> 75000+ records.  I was wondering if there was some way to find out how
many
> records matched the query so I can break out of this loop.

> If this is useful information, the member variables are continually
filled
> with the
> values that are matched by the query so the query appears to be record,
but
> it's looping through the same 7 records that match the query 75,000 times
> (and that's a REAL performance issue).  Any help is appreciated.  Thanks.



Sat, 25 Mar 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. CRecordset-Predefined query calling VB code

2. CRecordset join query issues

3. Opening a Parameterised Access Query as CRecordSet

4. Opening Parameter Based Access Query as CRecordSet

5. CRecordset CanUpdate query failure for Open in read write mode

6. CRecordset, Oracle7.3 and parameterized queries

7. MFC CRecordset query about a string

8. Query hangs using CRecordset::Open()

9. default SQL query time out for CRecordset

10. Opening a Parameterised Access Query as CRecordSet

11. CRecordset: predefined queries with parameters that have an apostrophe

12. Parameterized query using CRecordset

 

 
Powered by phpBB® Forum Software