Thread View: borland.public.cppbuilder.database.ado
6 messages
6 total messages
Started by George Nakos
Tue, 30 Aug 2005 13:00
How to retrieve data from an ADO query
Author: George Nakos
Date: Tue, 30 Aug 2005 13:00
Date: Tue, 30 Aug 2005 13:00
31 lines
1692 bytes
1692 bytes
Greetings, I know that this topic should tire you as I suspect that it has been answered a lot of times, but the answers I read didn't cover my needs. My situation is this: I am using a TADOQuery to do some SQL queries to an MS Access database. This works fine, and I can even put the results in a dataset and display them using TDBText objects on screen. My problem is that I don't want to display the data on screen, just store them in arrays and use them whenever necessary. If someone could provide a step-by-step process on how to do this, and providing a few lines of sample code, I would be most grateful. Thanks, George Nakos -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: How to retrieve data from an ADO query
Author: Vladimir Stefanovic
Date: Tue, 30 Aug 2005 13:55
Date: Tue, 30 Aug 2005 13:55
41 lines
2218 bytes
2218 bytes
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();
}
--
Best regards,
Vladimir Stefanovic
"George Nakos" <gnakos@metronco.gr> wrote in message
news:op.swbnqgj9qf2fxd@promitheas.metron.internal...
Greetings,
I know that this topic should tire you as I suspect that it has been
answered a lot of times, but the answers I read didn't cover my needs.
My situation is this: I am using a TADOQuery to do some SQL queries to an
MS Access database. This works fine, and I can even put the results in a
dataset and display them using TDBText objects on screen.
My problem is that I don't want to display the data on screen, just store
them in arrays and use them whenever necessary.
If someone could provide a step-by-step process on how to do this, and
providing a few lines of sample code, I would be most grateful.
Thanks,
George Nakos
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: How to retrieve data from an ADO query
Author: George Nakos
Date: Tue, 30 Aug 2005 14:16
Date: Tue, 30 Aug 2005 14:16
25 lines
1676 bytes
1676 bytes
On Tue, 30 Aug 2005 16:55:20 +0300, Vladimir Stefanovic
<antivari@po.sbb.co.yu> wrote:
> 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();
> }
>
>
>
Thanks a bunch! I'll give it a shot and tell you what happens!
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: How to retrieve data from an ADO query
Author: Viatcheslav V. Vassiliev
Date: Tue, 30 Aug 2005 16:58
Date: Tue, 30 Aug 2005 16:58
63 lines
2920 bytes
2920 bytes
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();
}
//------------------------------------------
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)
"Vladimir Stefanovic" <antivari@po.sbb.co.yu> �������/�������� � ��������
���������: 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();
> }
>
>
>
> --
> Best regards,
> Vladimir Stefanovic
> "George Nakos" <gnakos@metronco.gr> wrote in message
> news:op.swbnqgj9qf2fxd@promitheas.metron.internal...
> Greetings,
>
> I know that this topic should tire you as I suspect that it has been
> answered a lot of times, but the answers I read didn't cover my needs.
>
> My situation is this: I am using a TADOQuery to do some SQL queries to an
> MS Access database. This works fine, and I can even put the results in a
> dataset and display them using TDBText objects on screen.
>
> My problem is that I don't want to display the data on screen, just store
> them in arrays and use them whenever necessary.
>
> If someone could provide a step-by-step process on how to do this, and
> providing a few lines of sample code, I would be most grateful.
>
>
>
> Thanks,
> George Nakos
>
> --
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
>
Re: How to retrieve data from an ADO query
Author: George Nakos
Date: Wed, 31 Aug 2005 06:58
Date: Wed, 31 Aug 2005 06:58
43 lines
2241 bytes
2241 bytes
> "Vladimir Stefanovic" <antivari@po.sbb.co.yu> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
> ÓÌÅÄÕÀÝÅÅ: 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/
Re: How to retrieve data from an ADO query
Author: 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/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads