Article View: borland.public.cppbuilder.database.ado
Article #4114Re: How to write a select statement to search ....
From: Formentz
Date: Wed, 20 Mar 2002 08:43
Date: Wed, 20 Mar 2002 08:43
44 lines
2301 bytes
2301 bytes
you can do so :
ADOQuery->SQL->Text="select * from Table1 where field1 like '%'+ :param1
+'%'";
ADOQuery->Parameters->ParamByName("param1")->Value="test it";
ADOQuery->Open();
The like statement has the jolly chars % and _
% = any string of any length (like the * in the windows or dos file search)
_ = any character, length 1 (like the ? in the windows or dos file search)
Depending on the database you are connecting to, you have to include the
special characters in the parameter or in the way I wrote.
HTH
Ciao
Formentz
"Daniel Zhou" <langou@gmx.de> ha scritto nel messaggio
news:3c980ae5_2@dnews...
> Hi,
> I want to search a substring in a table. How can I write a select
statement
> to do it?
> For example:
> I want to find all record in Table Content where Content.Field1 include
the
> substring "Test it".
> Is it correct:
>
> Select * from content where "Test it" in field1.
>
> How can I write it in C++ Builder?
>
> ADOQuery -> SQL->ADD("Select * from Content where :field1 in field1");
> ADOQuery->Parameters->ParamByName("field1")->Value= "Test it";
> ADOQuery -> Open();
>
> Please help me?
>
> thanks!
>
> Daniel
>
>
Technical Details
Message-ID:
<3c984b8c_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!207.217.77.43.MISMATCH!newsfeed1.earthlink.net!newsfeed.earthlink.net!feed2.news.rcn.net!rcn!cpk-news-hub1.bbnplanet.com!news.gtei.net!dca6-feed1.news.digex.net!sfo2-feed1.news.digex.net!intermedia!news-out.spamkiller.net!propagator-la!news-in-la.newsfeeds.com!news-in.superfeed.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3c980ae5_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,d18756633b55898c X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2002-03-20 00:44:51 PST From: "Formentz" <francesco@leotron.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3c980ae5_2@dnews> Subject: Re: How to write a select statement to search .... Date: Wed, 20 Mar 2002 09:43:25 +0100 Lines: 46 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 80.16.99.17 Message-ID: <3c984b8c_2@dnews> X-Trace: dnews 1016613772 80.16.99.17 (20 Mar 2002 00:42:52 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!207.217.77.43.MISMATCH!newsfeed1.earthlink.net!newsfeed.earthlink.net!feed2.news.rcn.net!rcn!cpk-news-hub1.bbnplanet.com!news.gtei.net!dca6-feed1.news.digex.net!sfo2-feed1.news.digex.net!intermedia!news-out.spamkiller.net!propagator-la!news-in-la.newsfeeds.com!news-in.superfeed.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews