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: -
<%
-
Dim Keywords
-
Keywords = "%"
-
if (Request("search1") <> "") then Keywords = Request("search1")
-
%>
-
<%
-
MatchType = "AND"
-
If Keywords <> "" Then ' If there is something in the Keywords
-
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
-
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.
-
If (MatchType <> "EXACT") Then ' If Searchtype is not EXACT
-
Keywords = Replace(Keywords, ","," ") ' Replace any commas, colons, semicolons, dashes, undersores,
-
Keywords = Replace(Keywords, ":"," ") ' forward slashes or back slashes in the text entered in the
-
Keywords = Replace(Keywords, ";"," ") ' Keywords text field with a space.
-
Keywords = Replace(Keywords, "-"," ")
-
Keywords = Replace(Keywords, "_"," ")
-
Keywords = Replace(Keywords, "/"," ")
-
Keywords = Replace(Keywords, "\"," ")
-
WhereKeywordsString = " WHERE " & SearchFields & " LIKE '%" ' The SQL SELECT statement WHERE clause stored as a Text String in a Variable called WhereKeywordsString
-
-
SearchArray = Split(Keywords," ") ' Split the Keywords that are now separated by spaces and store them in an array
-
For i = 0 to Ubound(SearchArray) ' Repeat the following for each word in the array
-
If i > 0 Then
-
WhereKeywordsString = WhereKeywordsString & " " & MatchType & " " & SearchFields & " LIKE '%" & SearchArray(i) & "%'" ' Builds the SQL statement substituting AND / OR as defined by MatchType
-
Else
-
WhereKeywordsString = WhereKeywordsString & SearchArray(i) & "%'" ' If there is only one word in the array
-
End If
-
Next
-
Else
-
WhereKeywordsString = " WHERE kandidaten LIKE '%" & Keywords & "%'" 'If the SearchType selected was EXACT
-
End If ' End If searchtype is not EXACT
-
End if
-
%>
-
<%
-
set Recordset1 = Server.CreateObject("ADODB.Recordset")
-
Recordset1.ActiveConnection = MM_itcag_STRING
-
Recordset1.Source = "SELECT * FROM kandidaten" & WhereKeywordsString ' Here we've added or WhereKeywordsString variable
-
Recordset1.CursorType = 0
-
Recordset1.CursorLocation = 2
-
Recordset1.LockType = 3
-
Recordset1.Open()
-
Recordset1_numRows = 0
-
%>
-
i would appreciate to get some help how i could search in another 3 fields.
thanks for your help.
regs tom
9 2237 MMcCarthy 14,534
Recognized Expert Moderator MVP
Tom
What is this written in?
Mary
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 : - WhereKeywordsString = _
-
"WHERE ([kandidat]" & WhereKeywordsString & _
-
") OR ([ExtraField1]" & WhereKeywordsString & _
-
") OR ([ExtraField2]" & WhereKeywordsString & _
-
") OR ([ExtraField3]" & WhereKeywordsString & ")"
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.
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.
Tom
What is this written in?
Mary
hello mary,
it is written in a asp page.
regs tom
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 : - WhereKeywordsString = _
-
"WHERE ([kandidat]" & WhereKeywordsString & _
-
") OR ([ExtraField1]" & WhereKeywordsString & _
-
") OR ([ExtraField2]" & WhereKeywordsString & _
-
") OR ([ExtraField3]" & WhereKeywordsString & ")"
-> THANKS. i will try that. have a good day, tom
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
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 : - WhereKeywordsString = _
-
"WHERE ([kandidat]" & WhereKeywordsString & _
-
") OR ([ExtraField1]" & WhereKeywordsString & _
-
") OR ([ExtraField2]" & WhereKeywordsString & _
-
") 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
NeoPa 32,564
Recognized Expert Moderator MVP
From post #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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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();
|
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...
|
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...
| |
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
|
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
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
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...
| |