🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #3067

Re: How to copy query result to array or list?

#3067
From: Alen Markov
Date: Thu, 09 Jan 2003 18:16
64 lines
2689 bytes
I had a similar problem... made a query and then wanted to
fill a combobox with the found data in a column...
I guess there is for sure a much more elegant method, but
here is how I did it:
(If somebode has a better idea, plz post it - thanks...)

//--------------------------------------------------------------------------
--------
   //Make sure all CD's are displayed:
   AnsiString sqlStatement;
   sqlStatement = "SELECT * FROM CD";
   ADOQuery1->Close();
   ADOQuery1->SQL->Clear();
   ADOQuery1->SQL->Add(sqlStatement);
   ADOQuery1->Open();

   //Fill the combobox CD with values displayed in column1 (0 would be the
first one)
   int iRows = ADOQuery1->RecordCount;

   ADOQuery1->First();

   for(int i=0; i<iRows; i++)
   {
      if(i == 0)
      {
         //Items[1] means 2nd Column in DBGrid...
         ComboCD->Items->Add(DBGridCD->Columns->Items[1]->Field->AsString);
      }
      else
      {
         ADOQuery1->MoveBy(1);
         ComboCD->Items->Add(DBGridCD->Columns->Items[1]->Field->AsString);
      }
   }
//--------------------------------------------------------------------------
--------


Instead of filling a combobox you can fill your array...


Cheers

Alen

--
WEB: http://www.come.to/nostromo





"Richard" <ajyi@yam.com> wrote in message
news:3e1d93cd$2@newsgroups.borland.com...
> Hi all,
>
> Because I use recursive function to solve some problem. I need to copy the
> query result to local set and operate these data. How to do that? Is there
> any easy way to do that?
>
> Thanks
>
>
Technical Details
Message-ID: <3e1dbca7@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!gestalt.direcpc.com!news.stealth.net!news.stealth.net!news.imp.ch!news.imp.ch!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3e1d93cd$2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,e9c078c8abaf712b
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2003-01-09 10:39:57 PST
From: "Alen Markov" <NOSPAM_amarkov@gmx.net>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3e1d93cd$2@newsgroups.borland.com>
Subject: Re: How to copy query result to array or list?
Date: Thu, 9 Jan 2003 19:16:55 +0100
Lines: 66
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 80.218.79.120
Message-ID: <3e1dbca7@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1042136231 80.218.79.120 (9 Jan 2003 10:17:11 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!gestalt.direcpc.com!news.stealth.net!news.stealth.net!news.imp.ch!news.imp.ch!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail