Article View: borland.public.cppbuilder.database.ado
Article #519Re: How to retrieve data from an ADO query
From: Viatcheslav V. Vassiliev
Date: Wed, 31 Aug 2005 12:57
Date: Wed, 31 Aug 2005 12:57
60 lines
3257 bytes
3257 bytes
>Firstly, thanks a LOT for this snippet! It works like a charm!
This thank if for Vladimir Stefanovic.
>Hmm, the only difference I can notice between the 2 bits of code is the
>2nd doesn't use RecordCount. Is this the "unoptimised, slow and buggy" bit?
Yes. It will work on client-side cursor, but on server-side cursor
RecordCount may be, and usually is, very expensive (time, resources)
operation (specially in case of complex joins).
Also, when you scroll dataset, another user may add or delete rows to/from
table, depending on settings this may be reflected on dataset, i.e. when you
start scroll RecordCount is one number, but when you finish it may differ.
Check for EOF is more reliable in this case.
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"George Nakos" <gnakos@metronco.gr> �������/�������� � �������� ���������:
news:op.swc1m3q7qf2fxd@promitheas.metron.internal...
> "Vladimir Stefanovic" <antivari@po.sbb.co.yu> OIIAYEI/OIIAYEIA ? II?IOONE
> OIAAOAYAA: news:4314651e@newsgroups.borland.com...
>> Something like this /UNTESTED!!!/
>>
>> ADOQuery1->Open();
>>
>> for ( int i=0; i<ADOQuery1->RecordCount; i++ )
>> {
>> AnsiString ROW = ADOQuery1->FieldValues["Field1"] + ", " +
>> ADOQuery1->FieldValues["Field2"];
>> SomeStringList->Add( ROW );
>> ADOQuery1->Next();
>> }
Firstly, thanks a LOT for this snippet! It works like a charm!
> Usually it is very not optimized, in some cases may be slow and in some
> cases buggy. Better way is:
>
> ADOQuery1->Open();
> while (!ADOQuery->EOF)
> {
> .....
> ADOQuery1->Next();
> }
>
Hmm, the only difference I can notice between the 2 bits of code is the
2nd doesn't use RecordCount. Is this the "unoptimised, slow and buggy" bit?
Regards,
George Nakos
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Technical Details
Message-ID:
<4315a923$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<op.swbnqgj9qf2fxd@promitheas.metron.internal> <4314651e@newsgroups.borland.com> <43148ffa@newsgroups.borland.com> <op.swc1m3q7qf2fxd@promitheas.metron.internal>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,8fb1b60fd2dcc362 X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <op.swbnqgj9qf2fxd@promitheas.metron.internal> <4314651e@newsgroups.borland.com> <43148ffa@newsgroups.borland.com> <op.swc1m3q7qf2fxd@promitheas.metron.internal> Subject: Re: How to retrieve data from an ADO query Date: Wed, 31 Aug 2005 16:57:53 +0400 Lines: 62 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 85.93.138.132 Message-ID: <4315a923$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1125493027 85.93.138.132 (31 Aug 2005 05:57:07 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail