all groups > inetserver asp db > march 2007 >
You're in the

inetserver asp db

group:

Help With Field Searching Using Wildcards


Help With Field Searching Using Wildcards Andy
3/27/2007 11:25:48 AM
inetserver asp db:
Hi Gang

I have a small database application where the user can search
different fields. They select what they want to search on and enter a
value to search on. For example

They select part number and enter "123" into the search field.

This searches the database for that field with LIKE '%123%'.

What I want the user to be able to do is add wildcards to the search.
For example

They select the part description field and enter "Dohicky*123" or
"Dohicky?123"

I want the search to process the wildcards as you would expect. What
is the easiest way to do this?

Regards,
Andy
Re: Help With Field Searching Using Wildcards Andy
3/27/2007 11:42:00 AM
Hi Bob

Just to confirm... % is equal to * and _ is equal to ?

Is that right?

Regards,
Andy
Re: Help With Field Searching Using Wildcards Andy
3/27/2007 12:06:36 PM
Thanks Bob

That's exactly what I needed to know. Right now we'll just add the *
as that's all our users want. Our data shouldn't have a * in it.

Regards,
Andy
Re: Help With Field Searching Using Wildcards Bob Barrows [MVP]
3/27/2007 2:39:03 PM
[quoted text, click to view]
The same way. Only have your users use the ODBC wildcards (% and _) not
the Jet wildcards
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Re: Help With Field Searching Using Wildcards Bob Barrows [MVP]
3/27/2007 3:00:34 PM
[quoted text, click to view]
Yes.
You could allow the user to enter the jet wildcards and simply replace
them with the ODBC wildcards before putting the string into the query
.... but then you get into all the "escaping" issues, which I'm sure you
haven't thought through: what if the user wants to search for a string
containing those literal characters?
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

AddThis Social Bookmark Button