🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: DBGrid one more time ?

#3608
From: Ola Eriksen
Date: Thu, 18 Jul 2002 09:10
62 lines
2431 bytes
Hi!


First you have to place some object so you can access your database.
1 DataSource linked to the database
2 Table with the tabels you want to use.
1 SQLQuery compontent.

Code for running a SQL statement could be something like this:

    szSQLStatement = "SELECT SELECT LName, FName, Name FROM Person,
PersonHistory, Company
                                   WHERE Person.PersonID =
PersonHistory.PersonID AND ersonHistory.CompanyID = Company.CompanyID");
    Query->Close();
    Query->SQL->Clear();
    Query->SQL->Add(szSQLStatement);
    Query->Open();
    Query->First();

    while(!Query->IsEmpty())
    {
       //Do something with the fetched data.
       Query->Next();
    }




/Ola



Uros Obradovic wrote:

> Hi guys,
> I'm having with DBGrid, actually I would say I don't know how to do
> following.
>
> In DBGrid control, I have 4 Columns
> - Last Name
> - First Name
> - Company Name
>
> where Last Name and First Name are from one table, and Company Name from the
> other.
> Last Name and First Name columns are pointing to LName and FName fields in
> Person Table respectively,
> but Company Name is in the other table.
> I would like to use the following SQL statement and have the results in
> Company Name column.
>
> SELECT LName, FName, Name
> FROM Person, PersonHistory, Company
> WHERE Person.PersonID = PersonHistory.PersonID
> AND PersonHistory.CompanyID = Company.CompanyID
>
> How can I do that ?
> Hope you understand my question
>
> Thanks
> Uros
Technical Details
Message-ID: <3D368607.5BE075A6@callcom.no>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!priapus.visi.com!news-out.visi.com!hermes.visi.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews
References: <3d35d23e$1_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,b0601243ddb1b151
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2002-07-18 01:21:25 PST
Message-ID: <3D368607.5BE075A6@callcom.no>
Date: Thu, 18 Jul 2002 10:10:31 +0100
From: Ola Eriksen <ola@callcom.no>
X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Re: DBGrid one more time ?
References: <3d35d23e$1_2@dnews>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 193.69.252.248
X-Trace: dnews 1026979848 193.69.252.248 (18 Jul 2002 01:10:48 -0700)
Lines: 63
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!priapus.visi.com!news-out.visi.com!hermes.visi.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews