Position on a specific record in ODBC/ADO 
Author Message
 Position on a specific record in ODBC/ADO

Quote:

> Assuming that I have an open recordset, ADORecordset or CRecordset,
> containing records, How can I position myself to a specific record if I know
> some of the data, like 'state' and 'suburb'?

> In DAO I'd just create a filter string and apply it with one of the
> FindXXX() methods, which within the open recordset will potistion itself to
> the corrct record(s). How do I do this in ADO/ODBC without
> reopening/requerying the entire recordset?

> Sally Mendoza

m_strFilter.  I *think* this is a member of CRecordset, but it doesn't
appear so in the project I'm currently working on.  (There's something
screwed up somewhere with it, because the member list and other helpers
in VStudio are broken elsewhere.)

Set the string to the expression you want to filter, then Requery().  Do
not include the WHERE, just the comparative expression.

--
Lynn Wallace                           http://www.*-*-*.com/ ~lawall
Be patient!  It took us forty million years for us to develop a thumb.
 It'll probably take us forty million years to get it out of our ass.



Sat, 31 Aug 2002 03:00:00 GMT  
 Position on a specific record in ODBC/ADO
Assuming that I have an open recordset, ADORecordset or CRecordset,
containing records, How can I position myself to a specific record if I know
some of the data, like 'state' and 'suburb'?

In DAO I'd just create a filter string and apply it with one of the
FindXXX() methods, which within the open recordset will potistion itself to
the corrct record(s). How do I do this in ADO/ODBC without
reopening/requerying the entire recordset?

Sally Mendoza



Sun, 01 Sep 2002 03:00:00 GMT  
 Position on a specific record in ODBC/ADO

Will that close and open the recordset? This might be a costly operation.

Sally Mendoza


Quote:

> > Assuming that I have an open recordset, ADORecordset or CRecordset,
> > containing records, How can I position myself to a specific record if I
know
> > some of the data, like 'state' and 'suburb'?

> > In DAO I'd just create a filter string and apply it with one of the
> > FindXXX() methods, which within the open recordset will potistion itself
to
> > the corrct record(s). How do I do this in ADO/ODBC without
> > reopening/requerying the entire recordset?

> > Sally Mendoza

> m_strFilter.  I *think* this is a member of CRecordset, but it doesn't
> appear so in the project I'm currently working on.  (There's something
> screwed up somewhere with it, because the member list and other helpers
> in VStudio are broken elsewhere.)

> Set the string to the expression you want to filter, then Requery().  Do
> not include the WHERE, just the comparative expression.

> --
> Lynn Wallace                          http://www.xmission.com/~lawall
> Be patient!  It took us forty million years for us to develop a thumb.
>  It'll probably take us forty million years to get it out of our ass.



Sun, 01 Sep 2002 03:00:00 GMT  
 Position on a specific record in ODBC/ADO
For ADO, look at the Recordset property "Filter", and the methods "Find" and
"Seek".  Filter allows you to skip over Recordset rows that don't match the
criteria.  The Find and Seek bring you to a specific row depending on the
criteria you supply.


Quote:
> Assuming that I have an open recordset, ADORecordset or CRecordset,
> containing records, How can I position myself to a specific record if I
know
> some of the data, like 'state' and 'suburb'?

> In DAO I'd just create a filter string and apply it with one of the
> FindXXX() methods, which within the open recordset will potistion itself
to
> the corrct record(s). How do I do this in ADO/ODBC without
> reopening/requerying the entire recordset?

> Sally Mendoza



Sun, 01 Sep 2002 03:00:00 GMT  
 Position on a specific record in ODBC/ADO

I need more than one column in my find statement, Find does not handle that


Quote:
> For ADO, look at the Recordset property "Filter", and the methods "Find"
and
> "Seek".  Filter allows you to skip over Recordset rows that don't match
the
> criteria.  The Find and Seek bring you to a specific row depending on the
> criteria you supply.



> > Assuming that I have an open recordset, ADORecordset or CRecordset,
> > containing records, How can I position myself to a specific record if I
> know
> > some of the data, like 'state' and 'suburb'?

> > In DAO I'd just create a filter string and apply it with one of the
> > FindXXX() methods, which within the open recordset will potistion itself
> to
> > the corrct record(s). How do I do this in ADO/ODBC without
> > reopening/requerying the entire recordset?

> > Sally Mendoza



Sun, 01 Sep 2002 03:00:00 GMT  
 Position on a specific record in ODBC/ADO
Ah, but you can still use the "Filter" property.  If you are specific, you
can be left with 1 row.  Filter automatically moves you to the first row
meeting the Filter criteria.  At the very least, only those rows that meet
your criteria are left.  So just loop through the Recordset.  Good luck.


Quote:

> I need more than one column in my find statement, Find does not handle
that



> > For ADO, look at the Recordset property "Filter", and the methods "Find"
> and
> > "Seek".  Filter allows you to skip over Recordset rows that don't match
> the
> > criteria.  The Find and Seek bring you to a specific row depending on
the
> > criteria you supply.



> > > Assuming that I have an open recordset, ADORecordset or CRecordset,
> > > containing records, How can I position myself to a specific record if
I
> > know
> > > some of the data, like 'state' and 'suburb'?

> > > In DAO I'd just create a filter string and apply it with one of the
> > > FindXXX() methods, which within the open recordset will potistion
itself
> > to
> > > the corrct record(s). How do I do this in ADO/ODBC without
> > > reopening/requerying the entire recordset?

> > > Sally Mendoza



Sun, 01 Sep 2002 03:00:00 GMT  
 Position on a specific record in ODBC/ADO
For ODBC, I resorted to closing, setting a filter, and opening the database
each time.  I expected it to be slow, but it works fast enough for me.  A
FIND would certainly be nicer, and cleaner, but...

Quote:

>Assuming that I have an open recordset, ADORecordset or CRecordset,
>containing records, How can I position myself to a specific record if I
know
>some of the data, like 'state' and 'suburb'?

>In DAO I'd just create a filter string and apply it with one of the
>FindXXX() methods, which within the open recordset will potistion itself to
>the corrct record(s). How do I do this in ADO/ODBC without
>reopening/requerying the entire recordset?

>Sally Mendoza



Sun, 01 Sep 2002 03:00:00 GMT  
 Position on a specific record in ODBC/ADO
Sally Mendoza schrieb:

Quote:



> > > Assuming that I have an open recordset, ADORecordset or CRecordset,
> > > containing records, How can I position myself to a specific record if I
> know
> > > some of the data, like 'state' and 'suburb'?

> > > In DAO I'd just create a filter string and apply it with one of the
> > > FindXXX() methods, which within the open recordset will potistion itself
> to
> > > the corrct record(s). How do I do this in ADO/ODBC without
> > > reopening/requerying the entire recordset?

> > m_strFilter.  I *think* this is a member of CRecordset, but it doesn't

> > Set the string to the expression you want to filter, then Requery().  Do
> > not include the WHERE, just the comparative expression.

> Will that close and open the recordset? This might be a costly operation.

Hi Sally,

no it will not if you use member variables in your CRecordset to hold
parameter values so that you only have to do requery calls.

Search for the article "Recordset: Parameterizing a Recordset (ODBC)" on
your VisualC++ CD or in the MS knowledge base. In this article you will
find the following tip describing the advantage of parameters opposed to
filters:

"Using a parameter is more efficient than simply a filter. For a
parametrized recordset, the database must process an SQL SELECT
statement only once. For a filtered recordset without parameters, the
SELECT statement must be processed each time you requery with a new
filter value."

HTH
Olaf
--
           o      _    _        _      gofreyer      ofreyer

 _< \_   _>(_) (_)/<_   \_| \  _|/'\/                _________________
(_)>(_) (_)        (_)  (_)   (_)' _\o_              Geerd-Olaf Freyer



Sun, 01 Sep 2002 03:00:00 GMT  
 Position on a specific record in ODBC/ADO

and will it be slow in ADO?
That is the problem we are having?

Sally Mendoza


Quote:
> Sally Mendoza schrieb:




> > > > Assuming that I have an open recordset, ADORecordset or CRecordset,
> > > > containing records, How can I position myself to a specific record
if I
> > know
> > > > some of the data, like 'state' and 'suburb'?

> > > > In DAO I'd just create a filter string and apply it with one of the
> > > > FindXXX() methods, which within the open recordset will potistion
itself
> > to
> > > > the corrct record(s). How do I do this in ADO/ODBC without
> > > > reopening/requerying the entire recordset?

> > > m_strFilter.  I *think* this is a member of CRecordset, but it doesn't

> > > Set the string to the expression you want to filter, then Requery().
Do
> > > not include the WHERE, just the comparative expression.

> > Will that close and open the recordset? This might be a costly
operation.

> Hi Sally,

> no it will not if you use member variables in your CRecordset to hold
> parameter values so that you only have to do requery calls.

> Search for the article "Recordset: Parameterizing a Recordset (ODBC)" on
> your VisualC++ CD or in the MS knowledge base. In this article you will
> find the following tip describing the advantage of parameters opposed to
> filters:

> "Using a parameter is more efficient than simply a filter. For a
> parametrized recordset, the database must process an SQL SELECT
> statement only once. For a filtered recordset without parameters, the
> SELECT statement must be processed each time you requery with a new
> filter value."

> HTH
> Olaf
> --
>            o      _    _        _      gofreyer      ofreyer

>  _< \_   _>(_) (_)/<_   \_| \  _|/'\/                _________________
> (_)>(_) (_)        (_)  (_)   (_)' _\o_              Geerd-Olaf Freyer



Mon, 02 Sep 2002 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. ODBC-SDK, DAO, ADO ? // ADO: doc, version

2. return specific start and end position within a string

3. Calc value at specific decimal position for PI

4. Finding a Specific DB Record

5. Records from stored proc without a specific class?

6. Making the mouse button events non-position specific?

7. Help: Move to specific record in CDaoRecordView

8. CEdit: set cursor to specific position

9. How truncate a file from a specific position?

10. Access table record position

11. table-type record position

12. table-type record position

 

 
Powered by phpBB® Forum Software