BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ADOQuery filter

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Alan T
Guest





PostPosted: Wed Apr 18, 2007 8:11 am    Post subject: ADOQuery filter Reply with quote



How do I make the filter something like 'LIKE' in SQL?
eg.
Name = 'John*'
so returns 'Johnny', 'Johnson', 'johnny', 'johnson'
Back to top
Paul Scott
Guest





PostPosted: Wed Apr 18, 2007 5:08 pm    Post subject: Re: ADOQuery filter Reply with quote



On Wed, 18 Apr 2007 05:24:02 +0100, Alan T <alanpltseNOSPAM (AT) yahoo (DOT) com.au>
wrote:

Quote:
How do I make the filter something like 'LIKE' in SQL?
eg.
Name = 'John*'
so returns 'Johnny', 'Johnson', 'johnny', 'johnson'


In SQL(server) (and Access-via-ADO) the wild card is a percent "%" not an
asterisk

name like 'John%'

--
Paul Scott
Information Management Systems
Macclesfield, UK.
Back to top
Alan T
Guest





PostPosted: Thu Apr 19, 2007 5:15 am    Post subject: Re: ADOQuery filter Reply with quote



Thanks.

Can I make it case insensitive?

"Paul Scott" <paul.scott (AT) removethis_infmansys (DOT) com> wrote in message
news:op.tqzaojuldgyzbd@ims-w15.infmansys.net...
On Wed, 18 Apr 2007 05:24:02 +0100, Alan T <alanpltseNOSPAM (AT) yahoo (DOT) com.au>
wrote:

Quote:
How do I make the filter something like 'LIKE' in SQL?
eg.
Name = 'John*'
so returns 'Johnny', 'Johnson', 'johnny', 'johnson'


In SQL(server) (and Access-via-ADO) the wild card is a percent "%" not an
asterisk

name like 'John%'

--
Paul Scott
Information Management Systems
Macclesfield, UK.
Back to top
Asim
Guest





PostPosted: Thu Apr 19, 2007 8:11 am    Post subject: Re: ADOQuery filter Reply with quote

Quote:

Can I make it case insensitive?


Hi Alan,

It is case insensitive only by default, but in case you want it to be
case sensitive use COLLATE

Name COLLATE SQL_Latin1_General_CP1_CS_AS like 'John%'

with results like 'Johnny', 'Johnson'
excluding 'johnny', 'johnson'

Regards,

Asim Khan

--- posted by geoForum on http://delphi.newswhat.com
Back to top
Alan T
Guest





PostPosted: Fri Apr 20, 2007 8:11 am    Post subject: Re: ADOQuery filter Reply with quote

Sorry, what I want to do is not using SQL but set the Filter property of the
ADOQuery component.

"Asim" <akasimkhan (AT) yahoo (DOT) com> wrote in message
news:4626daf5$1 (AT) newsgroups (DOT) borland.com...
Quote:

Can I make it case insensitive?


Hi Alan,

It is case insensitive only by default, but in case you want it to be
case sensitive use COLLATE

Name COLLATE SQL_Latin1_General_CP1_CS_AS like 'John%'

with results like 'Johnny', 'Johnson'
excluding 'johnny', 'johnson'

Regards,

Asim Khan

--- posted by geoForum on http://delphi.newswhat.com
Back to top
Asim
Guest





PostPosted: Fri Apr 20, 2007 8:11 am    Post subject: Re: ADOQuery filter Reply with quote

Hi Alan,

Set Filtered := True;

and EITHER implement the following method, something like

procedure TForm.ADOQueryFilterRecord(DataSet: TDataSet;
var Accept: Boolean);
begin
Accept:=(DataSet.FieldByName('State').Value='CA') or
(DataSet.FieldByName('State').Value=Null)
end;

OR

Filter := 'State = ' + QuotedStr('CA') + ' OR ' +
'State = NULL';


Regards,

Asim Khan

--- posted by geoForum on http://delphi.newswhat.com
Back to top
Steve Zimmelman
Guest





PostPosted: Wed Apr 25, 2007 8:11 am    Post subject: Re: ADOQuery filter Reply with quote

This works with MS SQL Server and the SQLOLEDB provider.

AdoQuery1.Filter = 'Name like ''John%'' ';
AdoQuery1.Filtered := True ;

-Steve-

"Alan T" <alanpltseNOSPAM (AT) yahoo (DOT) com.au> wrote in message
news:46259d43$1 (AT) newsgroups (DOT) borland.com...
Quote:
How do I make the filter something like 'LIKE' in SQL?
eg.
Name = 'John*'
so returns 'Johnny', 'Johnson', 'johnny', 'johnson'

Back to top
Alan T
Guest





PostPosted: Mon May 14, 2007 7:54 am    Post subject: Re: ADOQuery filter Reply with quote

Thanks.
It works.

"Steve Zimmelman" <skz (AT) charter (DOT) nospam.net> wrote in message
news:462ec2f4 (AT) newsgroups (DOT) borland.com...
Quote:
This works with MS SQL Server and the SQLOLEDB provider.

AdoQuery1.Filter = 'Name like ''John%'' ';
AdoQuery1.Filtered := True ;

-Steve-

"Alan T" <alanpltseNOSPAM (AT) yahoo (DOT) com.au> wrote in message
news:46259d43$1 (AT) newsgroups (DOT) borland.com...
How do I make the filter something like 'LIKE' in SQL?
eg.
Name = 'John*'
so returns 'Johnny', 'Johnson', 'johnny', 'johnson'



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.