Re: Is MoveFirst() required before Seek() to perform seek-and-scan?
- From: "Paul Baker" <paulb@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 2 Feb 2006 09:35:45 -0500
Oops, I meant that Borland's VCL is going to great lengths to try to be at
BOF.
Paul
"Paul Baker" <paulb@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:...
This code is taken from Borland's VCL, part of Delphi 7.
procedure TCustomADODataSet.InternalFirst;
begin
if not Recordset.BOF then
begin
Recordset.MoveFirst;
if Recordset.Supports(adMovePrevious) and not Recordset.BOF then
Recordset.MovePrevious;
end;
end;
It is called after the recordset is opened. They go to great lengths to
try to be on the first record! In this case, they are simply trying to be
consistent with their historical behaviour with the BDE and dBase files.
However, where is it documented what state the newly opened recordset
should be in? It seems to me that BOF or the first record are both things
an OLE DB Provider could be forgiven for doing in the absence of any
mandate.
Paul
"Stephen Howe" <sjhoweATdialDOTpipexDOTcom> wrote in message
news:OpIL5p$JGHA.1452@xxxxxxxxxxxxxxxxxxxxxxx
Adding a call to MoveFirst() right after Open() cures the problem --
MoveNext() no longer attempts to reset the record position after a
Seek().
Though I found a workaround, I am still wondering if this is as-designed
behavior or some weird bug caused by inconsistencies in my OLE DB
provider.
After searching the Internet, I was not able to find a single example of
seek-and-scan (indexed sequential access in ole' IBM-speak) using ADO
that
wouldn't call MoveFirst() before the first Seek(). Coincidence? Hidden
knowledge? Please enlighten me...
I think it is inconsistency in the OLE DB Provider.
Many times when a recordset is returned, the cursor is on the first
record.
But in this case it could at BOF.
Is rs.BOF true? If so then you want MoveFirst()
Stephen Howe
.
- Prev by Date: Re: Is MoveFirst() required before Seek() to perform seek-and-scan?
- Next by Date: Re: Is MoveFirst() required before Seek() to perform seek-and-scan?
- Previous by thread: Re: Is MoveFirst() required before Seek() to perform seek-and-scan?
- Next by thread: Re: RecordSet.Close Throwing Errors
- Index(es):
Relevant Pages
|
|