473,545 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

search candidates

3 New Member
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 2237
MMcCarthy
14,534 Recognized Expert Moderator MVP
Tom

What is this written in?

Mary
Feb 8 '07 #2
NeoPa
32,564 Recognized Expert Moderator MVP
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 'WhereKeywordsS tring' 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,564 Recognized Expert Moderator MVP
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 Recognized Expert Moderator MVP
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
tomjones75
3 New Member
Tom

What is this written in?

Mary
hello mary,

it is written in a asp page.
regs tom
Feb 8 '07 #6
tomjones75
3 New Member
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 'WhereKeywordsS tring' 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 Recognized Expert Moderator MVP
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 Top Contributor
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 'WhereKeywordsS tring' 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,564 Recognized Expert Moderator MVP
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
3866
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 more than 10 letters, and find all possible mutations that match a word in my dictionary (80k words). However a wildcard letter '?' is also an...
4
6037
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 across multiple columns in multiple tables and return a single list of results so that i can show unique records that are returned. The problem...
3
6588
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 &qr, Q3Canvas *canvas); Mosfet::~Mosfet();
0
1938
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 PROJECTS ON JAVA/J2EE. „« WE GOT MORE THEN 25 LIVE PROJECTS ON EMBEDED FOR ECE CANDIDATES. „« ALONG WITH PLACEMENT GUIDANCE FOR FINAL YEAR...
0
1231
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 THEN 30 LIVE PROJECTS ON JAVA/J2EE/STRUTS/EJB. „« WE GOT MORE THEN 30 LIVE PROJECTS ON EMBEDED FOR ECE CANDIDATES. „« WE GOT MORE THEN 20 LIVE PROJECTS...
2
2693
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 Exp in J2EE
0
1430
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 Infomedia http://jobpath.50webs.com/walkinsjobs.html Xansa Walk-in | ACS Walk-in | Sterlite (MNC) | WNS | HTMT & Fulcrum
0
7416
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7932
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7776
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5347
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4965
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3456
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1905
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
729
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.