This is a forum where members new and old can come to ask questions and get info and opinions. It is not a place to advertise your business or have other forms of advertising, whether it be in your posts or signature.

All links in the forum will not be indexed by Search Engines and any unapproved forms of advertising or spam will be dealt with accordingly, deleted, and that member's account banned.

Forums

Overview » ASP » Some help pls....
Reply

Some help pls....

metin yaman
Member



Since: 14 Feb 2002
Posts: 2
Posted 03 Apr 2010 07:41:57

I'm gonna ask for some help ...My question is very simple ...
i have codes like "abc 4515" or "abc 6525/2" in my access database .(pls note that there is "space" between the whole code ...)So all i wanna do is to find these details in my search result page BUT even if i write in search form "abc4515" or "a b c 4 5 1 5" i still want to find the codes or the code which is the closest one to the search ....?Pls at leats give me some idea about it ....If you can tell me what do i have to do or how do i have to do it (do i have to use function or something) i will appreciate it ...

Thanks in advance

Kind Regards
Metin

I'm gonna ask for some help ...My question is very simple ...
i have codes like "abc 4515" or "abc 6525/2" in my access database .(pls note that there is "space" between the whole code ...)So all i wanna do is to find these details in my search result page BUT even if i write in search form "abc4515" or "a b c 4 5 1 5" i still want to find the codes or the code which is the closest one to the search ....?Pls at leats give me some idea about it ....If you can tell me what do i have to do or how do i have to do it (do i have to use function or something) i will appreciate it ...

Thanks in advance

Kind Regards
Metin
metin yaman
Member



Since: 14 Feb 2002
Posts: 2
Replied 04 Apr 2010 21:27:01
Any idea ....? []
Javier Castro
Total freaking Member



Since: 09 Sep 2004
Posts: 454
Replied 05 Apr 2010 15:42:51
your SQL query should be something like:

SELECT * FROM myDB WHERE yourfield LIKE "Param%"

The above looks for anything that starts with a and whatever the rest of the word is. If the percentage sign is in from then the first work could be anything and the rest would be an approximation to the word your are searching for.

Hope it helps.
Patrick Woldberg
Official Representative



Since: 11 Feb 2003
Posts: 1,894
Replied 06 Apr 2010 12:06:07
When you're codes always have 3 characters and then some numbers you could try:

param = Replace(Request("Search"), " ", "")
If Len(param) > 3 Then
  param = Left(param, 3) & " " & Mid(param, 3)
End If
sql = "SELECT * FROM Table WHERE Code LIKE '" & Replace(param, "'", "''") & "%'"


You should probably do some more checking (using regexp) and I would suggest using ADODB.Command with parameters to protect yourself for sql injections.

Reply to this topic

Message
Reply
Follow us on Facebook Follow us on twitter Subscribe to the RSS feed
Activate your free membership today | Login | Currency