473,388 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

search candidates

dear community,

i want to search the content of all fields in one table in a access database.

it already works for the content of one field in the table.

please take a look at the code in the resultpage:

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim Keywords
  3. Keywords = "%"
  4. if (Request("search1")    <> "") then Keywords = Request("search1")   
  5. %>
  6. <%
  7. MatchType = "AND"
  8. If Keywords <> "" Then                         ' If there is something in the Keywords
  9.     SearchFields = "kandidat"            ' The Database table column in which we are going to look for matches to our Keywords stored as a Text String in a Variable called SearchFields
  10.     Keywords = Replace(Keywords, "'","''")     ' Replace any single quotes with 2 quotes, to stop the search failing, but allowing exact search to find matches with words with apostrophes. 
  11.     If (MatchType <> "EXACT") Then    ' If Searchtype is not EXACT        
  12.         Keywords = Replace(Keywords, ","," ")     ' Replace any commas, colons, semicolons, dashes, undersores,
  13.         Keywords = Replace(Keywords, ":"," ")     ' forward slashes or back slashes in the text entered in the
  14.         Keywords = Replace(Keywords, ";"," ")     ' Keywords text field with a space.
  15.         Keywords = Replace(Keywords, "-"," ")
  16.         Keywords = Replace(Keywords, "_"," ")
  17.         Keywords = Replace(Keywords, "/"," ")
  18.         Keywords = Replace(Keywords, "\"," ")
  19.         WhereKeywordsString = " WHERE " & SearchFields & " LIKE '%" ' The SQL SELECT statement WHERE clause stored as a Text String in a Variable called WhereKeywordsString
  20.  
  21.         SearchArray = Split(Keywords," ")     ' Split the Keywords that are now separated by spaces and store them in an array
  22.         For i = 0 to Ubound(SearchArray)     ' Repeat the following for each word in the array
  23.             If i > 0 Then
  24.                 WhereKeywordsString = WhereKeywordsString & " " & MatchType & " " & SearchFields & " LIKE '%" & SearchArray(i) & "%'" ' Builds the SQL statement substituting AND / OR as defined by MatchType
  25.             Else
  26.             WhereKeywordsString = WhereKeywordsString & SearchArray(i) & "%'" ' If there is only one word in the array 
  27.             End If    
  28.         Next
  29.     Else
  30.     WhereKeywordsString = " WHERE kandidaten LIKE '%" & Keywords & "%'" 'If the SearchType selected was EXACT
  31.     End If ' End If searchtype is not EXACT
  32. End if    
  33. %>
  34. <%
  35. set Recordset1 = Server.CreateObject("ADODB.Recordset")
  36. Recordset1.ActiveConnection = MM_itcag_STRING
  37.     Recordset1.Source = "SELECT * FROM kandidaten" & WhereKeywordsString ' Here we've added or WhereKeywordsString variable
  38. Recordset1.CursorType = 0
  39. Recordset1.CursorLocation = 2
  40. Recordset1.LockType = 3
  41. Recordset1.Open()
  42. Recordset1_numRows = 0
  43. %>
  44.  
i would appreciate to get some help how i could search in another 3 fields.

thanks for your help.
regs tom
Feb 7 '07 #1
9 2221
MMcCarthy
14,534 Expert Mod 8TB
Tom

What is this written in?

Mary
Feb 8 '07 #2
NeoPa
32,556 Expert Mod 16PB
This is quite a complicated and involved question.
I am not going to code this for you, but in principle, you need to build up the 'WhereKeywordsString' string to be just the part that is common to all the fields first.
Next you say something like :
Expand|Select|Wrap|Line Numbers
  1. WhereKeywordsString = _
  2.     "WHERE ([kandidat]" & WhereKeywordsString & _
  3.     ") OR ([ExtraField1]" & WhereKeywordsString & _
  4.     ") OR ([ExtraField2]" & WhereKeywordsString & _
  5.     ") OR ([ExtraField3]" & WhereKeywordsString & ")"
Feb 8 '07 #3
NeoPa
32,556 Expert Mod 16PB
Tom

What is this written in?

Mary
Mary,
I'm not sure, but I think this may be VB Script code.
The relevant bits seemed close enough to VBA though so I worked on that basis.

-Adrian.
Feb 8 '07 #4
MMcCarthy
14,534 Expert Mod 8TB
Mary,
I'm not sure, but I think this may be VB Script code.
The relevant bits seemed close enough to VBA though so I worked on that basis.

-Adrian.
Though it might be.
Feb 8 '07 #5
Tom

What is this written in?

Mary
hello mary,

it is written in a asp page.
regs tom
Feb 8 '07 #6
This is quite a complicated and involved question.
I am not going to code this for you, but in principle, you need to build up the 'WhereKeywordsString' string to be just the part that is common to all the fields first.
Next you say something like :
Expand|Select|Wrap|Line Numbers
  1. WhereKeywordsString = _
  2.     "WHERE ([kandidat]" & WhereKeywordsString & _
  3.     ") OR ([ExtraField1]" & WhereKeywordsString & _
  4.     ") OR ([ExtraField2]" & WhereKeywordsString & _
  5.     ") OR ([ExtraField3]" & WhereKeywordsString & ")"

-> THANKS. i will try that. have a good day, tom
Feb 8 '07 #7
MMcCarthy
14,534 Expert Mod 8TB
hello mary,

it is written in a asp page.
regs tom
I'm going to post a pointer question in the ASP forum as they may be better able to help.

Mary
Feb 8 '07 #8
hariharanmca
1,977 1GB
This is quite a complicated and involved question.
I am not going to code this for you, but in principle, you need to build up the 'WhereKeywordsString' string to be just the part that is common to all the fields first.
Next you say something like :
Expand|Select|Wrap|Line Numbers
  1. WhereKeywordsString = _
  2.     "WHERE ([kandidat]" & WhereKeywordsString & _
  3.     ") OR ([ExtraField1]" & WhereKeywordsString & _
  4.     ") OR ([ExtraField2]" & WhereKeywordsString & _
  5.     ") OR ([ExtraField3]" & WhereKeywordsString & ")"
Tom is using search for string char (like '%" & strValue & "%') if he use the above code there may possibility of selecting all record in that table or qry
Feb 9 '07 #9
NeoPa
32,556 Expert Mod 16PB
From post #1 :
Expand|Select|Wrap|Line Numbers
  1. SearchArray = Split(Keywords," ") 
strValue can only be empty if multiple spaces can find their way into Keywords.
If this is possible then you should look to handle it in your code.
Feb 9 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Case Nelson | last post by:
Hi there I've just been playing around with some python code and I've got a fun little optimization problem I could use some help with. Basically, the program needs to take in a random list of no...
4
by: dave | last post by:
I am wondering if the following can be done. I want to setup a search page that utilizes full text searching in sql2000. I want the user to type in say "where is bill" and have the query search...
3
by: Jeff | last post by:
Its been years since I did C++ and Im unsure what this is about. I have a QT class Im inheriting from in my .h file: class Mosfet : Q3CanvasRectangle { public: Mosfet::Mosfet(const QRect...
0
by: ravi.malashetty | last post by:
RAYLOGIX TECHNOLOGIES is now providing LIVE PROJECTS for M.TECH/B.E/ MCA/BCA (CSE/ISE/ECE)final year candidates.Interested candidates can directly come to the company. „« WE GOT MORE THEN 20 LIVE...
0
by: finalyearproject6 | last post by:
RAYLOGIX TECHNOLOGIES is now providing LIVE PROJECTS for M.TECH/MCA/ BCA/B.Sc/M.Sc/B.E (CSE/ISE/ECE)final year candidates.Interested candidates can directly come to the company. „« WE GOT MORE...
2
by: HariKutty | last post by:
Hi everybody, My Probs is I am having a table -RESUME It contains two columns CandidateID ResumeTitle 101 - 0 to 4 yrs of Exp in JAVA 102 - 1 t0 8 yrs of...
0
by: Career Point | last post by:
Perot, IBM, Hewlett-Packard, Dell, Wipro, HCL, Infosys, Satyam Hiring software Engineering candidates and MBA candidates Perot Walk-in: Aug 1-7 | Survik (MNC) Walk-in | E-Edit Solutions | Zenith...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.