Article View: borland.public.cppbuilder.database.ado
Article #2837Re: Accessing data from Access DB control issue different than SQL 2000?
From: Viatcheslav V. Vassiliev
Date: Thu, 06 Mar 2003 17:58
Date: Thu, 06 Mar 2003 17:58
85 lines
3748 bytes
3748 bytes
You provide just a part of your code. This part can produce unpredictable
results. Is DataSource1->DataSet = Query1? Does code below works?
Query1->SQL->Clear();
Query1->Close();
Query1->SQL->Add("SELECT Item_Name FROM table_name WHERE Group_Name =
'Lights'");
Query1->Active=true;
//Query1->Open(); //The same as Active = true
//Query1->ControlsDisabled();
Query1->First();
//int countmax=Query1->RecordCount; //do not use RecordCount, it may be
very slow
while (!Query1->Eof)
{
ListBox1->Items->Add(Query1->Fields->FieldByName("Item_Name")->AsString);
Query1->Next();
}
//for (int i=0;i<countmax;i++)
//{
// Query1->GetCurrentRecord(item_name); //do not get directly into
buffer - its implementation differs
//depending db access components - BDE, ADO etc.
// ListBox1->Items->Add(group_name); //you get data into item_name
but add here group_name
// Query1->Next();
//}
----------------------------------------------------------------
Regards,
Viatcheslav V. Vassiliev
http://www.oledbdirect.com
The fastest way to access MS SQL Server, MS Jet (MS Access)
and Interbase (through OLEDB) databases.
"Andrew" <houston@compusmart.ab.ca> �������/�������� � �������� ���������:
news:3e677f28$1@newsgroups.borland.com...
>
> Hi,
> I am using Window 98 SE, BCB5 Pro, Office XP Pro
> I hope this is the right forum.
>
> I have built a table in Access : (such as)
> Group_Name Item_Name
> --------------+----------
> Lights Interior
> Lights Exterior
> Power Doorway
> Power Window
>
> I can access the DB OK, put into a table, all is fine.
> When I try to query DB, the SQL does not seem to filter.
>
> Query1->SQL->Clear();
> Query1->Close();
> Query1->SQL->Add("SELECT Item_Name FROM table_name WHERE Group_Name =
'Lights'");
> Query1->Active=true;
> Query1->Open();
> DataSource1->DataSet->ControlsDisabled();
> DataSource1->DataSet->First();
> int countmax=DataSource1->DataSet->RecordCount;
> for (int i=0;i<countmax;i++)
> {
> DataSource1->DataSet->GetCurrentRecord(item_name);
> ListBox1->Items->Add(group_name);
> DataSource1->DataSet->Next();
> }
>
>
> This will list all contents of the database under Item_Name,
> even thought they don't match the Query criteria.
> It should only list the first two ?
>
> This worked for SQL 2000, but not for Access?
> how do I tweak this?
>
> Thanks in advance.
> Andrew
>
>
Technical Details
Message-ID:
<3e678c53@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!38.144.126.75.MISMATCH!feed1.newsreader.com!newsreader.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3e677f28$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10698b,e89b105f1cb46fd8 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2003-03-06 10:10:42 PST From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3e677f28$1@newsgroups.borland.com> Subject: Re: Accessing data from Access DB control issue different than SQL 2000? Date: Thu, 6 Mar 2003 20:58:10 +0300 Lines: 87 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: 213.247.201.57 Message-ID: <3e678c53@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1046973523 213.247.201.57 (6 Mar 2003 09:58:43 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!38.144.126.75.MISMATCH!feed1.newsreader.com!newsreader.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail