Help With Field Searching Using Wildcards
Help With Field Searching Using Wildcards
am 27.03.2007 20:25:48 von andy.mcvicker
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
am 27.03.2007 20:39:03 von reb01501
Andy wrote:
> 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?
>
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
am 27.03.2007 20:42:00 von andy.mcvicker
Hi Bob
Just to confirm... % is equal to * and _ is equal to ?
Is that right?
Regards,
Andy
Re: Help With Field Searching Using Wildcards
am 27.03.2007 21:00:34 von reb01501
Andy wrote:
> Hi Bob
>
> Just to confirm... % is equal to * and _ is equal to ?
>
> Is that right?
>
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.
Re: Help With Field Searching Using Wildcards
am 27.03.2007 21:06:36 von andy.mcvicker
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