|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
Can anyone help me with this last issue?
|
|
#17
|
||||
|
||||
|
The function is correct, i have checked it with static values.
Can you post example data of string you have and 3 search words? And i think that this is a case-sensitive also. I mean if you search for "I" then it doesnt highlight "i" |
|
#18
|
||||
|
||||
|
Here's an example of data in the resume_doc field.
Quote:
Now I want to search the resume_doc field for records that have these three keywords in that field ... Quote:
The results should include the record above and other records with these three words. -President, IBM, and sql should be highlighted in the resume_doc field when the results are returned. Does this make sense? Thanks for the help! I appreciate it |
|
#19
|
||||
|
||||
|
Hmm, this looks good!!
We'll have to debug it step-by-step. First check whether your sql is bringing desired records from database. Then response.write the records and the 3 search variables to make sure we getting all data. Be advised that values from Access memo fields can be accessed just once using such code rs("resume_doc") If you need it more than once, better save it in some variable and then use that variable. In the end, make sure all 4 variables (memo field and 3 search values) are being passed to the function. |
|
#20
|
|||
|
|||
|
the sql is fine. I also tested the sql in the Access database and it works perfectly. Now to get it working in asp is the challange. Still not sure how to get the results from the response.write to display properly on the webpage. Any ideas?
|
|
#21
|
|||
|
|||
|
I eliminated the highlight function just for a test
The response.write now looks liks this .. Code:
Response.Write ("<td>" & rs("resume_doc") & "</td>")
The page returns data but it is only using the first item entered as the criteria. The page appears to be ignoring the other 2 conditions in the sql. It should use all three criteria when doing the search. Can you explain what I'm doing wrong? I'm very new to asp and am struggling trying to get this to work. Thank you for your help and advice. |
|
#22
|
||||
|
||||
|
Hmm, the page cannot change the query and show its own records.
Either the query is wrong is wrong or we are missing something. Please latest relevant code. |
|
#23
|
|||
|
|||
|
Here's snippets of the code...
These are my variables Code:
strURL = Request.ServerVariables("URL")
Dim rstSearch ' ADO recordset
Dim strSearch ' The text being looked for
Dim strSearch1 ' The text being looked for
Dim strSearch2 ' The text being looked for
Dim strFind1
Dim strFind2
Dim strFind3
dim strColor
strSearch = Request.QueryString("search")
strSearch = Request.QueryString("search1")
strSearch = Request.QueryString("search2")
Here's the highlight function Code:
' Function Highlight(strText, strFind1, strFind2, strFind3, strColor) strText = cStr(strText) strText = Replace(strText,strFind1,"<font color=" & strColor & ">" & strFind1 & "</font>") strText = Replace(strText,strFind2,"<font color=" & strColor & ">" & strFind2 & "</font>") strText = Replace(strText,strFind3,"<font color=" & strColor & ">" & strFind3 & "</font>") Highlight = strText End Function Here's the text box on the form where the user inputs the text to search Code:
<p><B>Search and/or Update a Candidates' Record by the Resume Document field</B></p> <p></p> <p><B>Enter a key word you want to search for or % in the text box below</B></p> <p></p> <form action="<%= strURL %>" method="get"> <input name="search" value="<%= strSearch %>" /> <p> <p><B>Enter a second key word you want to search for or % in the text box below</B></p> <p></p> <input name="search1" value="<%= strSearch1 %>" /> <p> <p><B>Enter a third key word you want to search for or % in the text box below</B></p> <p></p> <input name="search2" value="<%= strSearch2 %>" /> <p> <input type="submit" /> </p> </form> <p></p> Here's the sql Code:
sql= "SELECT * " _
& "FROM [RSA_Candidates] " _
& "WHERE resume_doc LIKE '%"& Replace(strSearch, "'", "''") & "%' AND " _
& "resume_doc LIKE '%"& Replace(strSearch1, "'", "''") & "%' AND " _
& "resume_doc LIKE '%"& Replace(strSearch2, "'", "''") & "%' " _
& "ORDER BY lastname;"
Here's the response.write code with the highlight function...If you can show me how to use the highlight function here where it highlights the three key words in this statement that would be great... Code:
Response.Write "<table border=1 cellspacing=2>"
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Resume: " & "</B>" & "</td>")
'Response.Write ("<td>" & Highlight(rs("resume_doc"), StrSearch, StrSearch1, StrSearch2,"blue") & "</td>")
Response.Write ("<td>" & rs("resume_doc") & "</td>")
Response.Write ("</tr>")
Thank you for your help |
|
#24
|
|||
|
|||
|
can anyone review my last post and help me out?
I'd appreciate it. Thanks |
|
#25
|
||||
|
||||
|
I dont know whats the issue here, so i can only suggest that save the memo field in a variable first and then use it. Like
Code:
strDoc = rs("resume_doc")
Response.Write ("<td>" & Highlight(strDoc, StrSearch, StrSearch1, StrSearch2,"blue") & "</td>")
|
|
#26
|
|||
|
|||
|
I did as you suggested using the strDoc variable and now the page has an http 500 error. I'm pasting all the code below. Can you please review it and advise what it is I'm doing wrong?
Code:
<% @ LANGUAGE="VBScript" %>
<%
Option Explicit
Response.Buffer = True
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adUseClient = 3
Const adCmdText = 1
Dim conn, rs, sql
Dim strURL ' The URL of this page so the form will work
' Retreive the URL of this page from Server Variables
strURL = Request.ServerVariables("URL")
Dim rstSearch ' ADO recordset
Dim strSearch ' The text being looked for
Dim strSearch1 ' The text being looked for
Dim strSearch2 ' The text being looked for
Dim strFind1
Dim strFind2
Dim strFind3
dim strColor
Dim strDoc
strSearch = Request.QueryString("search")
strSearch = Request.QueryString("search1")
strSearch = Request.QueryString("search2")
strDoc = rs("resume_doc")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open("RSA_262093")
%>
<%
'
Function Highlight(strText, strFind1, strFind2, strFind3, strColor)
strText = cStr(strText)
strText = Replace(strText,strFind1,"<font color=" & strColor & ">" & strFind1 & "</font>")
strText = Replace(strText,strFind2,"<font color=" & strColor & ">" & strFind2 & "</font>")
strText = Replace(strText,strFind3,"<font color=" & strColor & ">" & strFind3 & "</font>")
Highlight = strText
End Function
'************************************************* ****************************
%>
<html>
<body bgcolor="#FFFFFF">
<p><B>Search and/or Update a Candidates' Record by the Resume Document field</B></p>
<p></p>
<p><B>Enter a key word you want to search for or % in the text box below</B></p>
<p></p>
<form action="<%= strURL %>" method="get">
<input name="search" value="<%= strSearch %>" />
<p>
<p><B>Enter a second key word you want to search for or % in the text box below</B></p>
<p></p>
<input name="search1" value="<%= strSearch1 %>" />
<p>
<p><B>Enter a third key word you want to search for or % in the text box below</B></p>
<p></p>
<input name="search2" value="<%= strSearch2 %>" />
<p>
<input type="submit" />
</p>
</form>
<p></p>
<%
If strSearch <> "" Then
Set rs = Server.CreateObject("ADODB.Recordset")
sql= "SELECT * " _
& "FROM [RSA_Candidates] " _
& "WHERE resume_doc LIKE '%"& Replace(strSearch, "'", "''") & "%' AND " _
& "resume_doc LIKE '%"& Replace(strSearch1, "'", "''") & "%' AND " _
& "resume_doc LIKE '%"& Replace(strSearch2, "'", "''") & "%' " _
& "ORDER BY lastname;"
rs.Open sql, conn, adOpenForwardOnly, adLockReadOnly, adCmdText
%>
<%
IF not Rs.EOF then
Do While not Rs.EOF
Response.Write "<FORM name='Update' method='post' action='UpdateT.asp'>"
Response.Write "<table border=1 cellspacing=2>"
Response.Write ("<tr>")
Response.Write("<td colspan='1' align='center'>"&"<input type ='submit' name='submit' value='Update' >"&"</td>")
Response.Write ("<td>" & " <input type='radio' name='ID' value=" & rs("ID") & "></td>")
Response.Write ("<td>" & "<B>" & "Last Name: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("LastName") & "</td>")
Response.Write ("<td>" & "<B>" & "First Name: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("FirstName") & "</td>")
Response.Write ("<td>" & "<B>" & "MI: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("MI") & "</td>")
Response.Write ("<td>" & "<B>" & "Title: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("title") & "</td>")
Response.Write ("<td>" & "<B>" & "Company: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("Company") & "</td>")
Response.Write "<table border=1 cellspacing=2>"
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Client: " & "</B>" & "</td>")
Response.Write ("<td> <font color='#FF0000'>" & rs("Client") & " </font></td>")
Response.Write ("<td rowspan=21 valign='top'>" & rs("Notes") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Industry: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("industry") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Discipline: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("discipline") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Compensation: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("compensation") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Cell Phone: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("cell_phone") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Office Phone: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("office_phone") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Home Phone: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("home_phone") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Fax: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("fax") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Email: " & "</B>" & "</td>")
Response.Write ("<td><A HREF=mailto:"& rs("email") & "> "& rs("email") &" </A></td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Address: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("address") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "City: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("City") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "State: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("state") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Zip: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("zip") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Relocation: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("Relocation") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Education: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("Education") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Affiliations: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("Affiliations") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Refered By: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("Refer_by") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Resume on File: " & "</B>" & "</td>")
Response.Write ("<td><A HREF=http://www.rsaexecsearch.com/rsa/resumes/" & rs("Resume") & "> "& rs("Resume") &"</A></td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "References: " & "</B>" & "</td>")
Response.Write ("<td><A HREF=http://www.rsaexecsearch.com/rsa/references/" & rs("References") & "> "& rs("References")
&"</A></td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Date of First Entry: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("Date_first_entry") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Date of Last Entry: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("Date_last_entry") & "</td>")
Response.Write ("</tr>")
Response.Write "<table border=1 cellspacing=2>"
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Resume: " & "</B>" & "</td>")
Response.Write ("<td>" & Highlight(strDoc, StrSearch, StrSearch1, StrSearch2,"blue") & "</td>")
Response.Write ("</tr>")
Response.Write ("<tr>")
Response.Write ("<td BGCOLOR=#ffff00 colspan=5> </td>")
Response.Write ("</tr>")
Response.Write ("</tr>")
Rs.MoveNext
Loop
else
Response.Write("No records found")
end if
Response.Write "</table>"
Response.Write "</table>"
Rs.Close
Set Rs = Nothing
Set Conn = Nothing
End If
%>
</form>
</body>
</html>
Thank you for your help and patience. I appreciate it |
|
#27
|
||||
|
||||
|
you have strDoc = rs("resume_doc")
in the wrong place remove it where you have it and put right after your do while loop - you cannot use it there because the recordset object (rs) has not been opened Code:
Do While not Rs.EOF
strDoc = rs("resume_doc")
Response.Write "<FORM name='Update' method='post' action='UpdateT.asp'>"
'...
also if using internet explorer...you can view detailed error messages by: tools>internet options>advanced>browsing>UNCHECK show friendly http error messages
__________________
Please give respect to those that helped solve an issue by clicking on the reputation icon
|
|
#28
|
|||
|
|||
|
Thank you. Now the page is appearing. It looks like the results are not meeting the criteria of the 3 values that are entered by the user. I believe my sql is correct
Code:
sql= "SELECT * " _
& "FROM [RSA_Candidates] " _
& "WHERE resume_doc LIKE '%"& Replace(strSearch, "'", "''") & "%' AND " _
& "resume_doc LIKE '%"& Replace(strSearch1, "'", "''") & "%' AND " _
& "resume_doc LIKE '%"& Replace(strSearch2, "'", "''") & "%' " _
& "ORDER BY lastname;"
Also the highlight function isn't working at all Code:
<% ' Function Highlight(strText, strFind1, strFind2, strFind3, strColor) strText = cStr(strText) strText = Replace(strText,strFind1,"<font color=" & strColor & ">" & strFind1 & "</font>") strText = Replace(strText,strFind2,"<font color=" & strColor & ">" & strFind2 & "</font>") strText = Replace(strText,strFind3,"<font color=" & strColor & ">" & strFind3 & "</font>") Highlight = strText End Function Any idea what is wrong here? Thank you again for the help. I'm pretty frustrated at this point. |
|
#29
|
|||
|
|||
|
does anything look wrong with the SQL? I need it to bring back the records that meet all 3 conditions that the user entered. Thanks for the help!
|
|
#30
|
|||
|
|||
|
Search multiple keyword search in a memo field using asp
Our user wants to do a search on a memo field in an Access database using 3 different keywords. The webpage is coded in ASP.
The memo field is called resume_doc. Here is the sql code in the asp page... Code:
sql= "SELECT * " _
& "FROM [RSA_Candidates] " _
& "WHERE resume_doc LIKE '%"& Replace(strSearch, "'", "''") & "%' AND " _
& "resume_doc LIKE '%"& Replace(strSearch1, "'", "''") & "%' AND " _
& "resume_doc LIKE '%"& Replace(strSearch2, "'", "''") & "%' " _
& "ORDER BY lastname;"
The user enters the 3 keywords in three different text boxes. Here is the code for the keyword entry...... Code:
<form action="<%= strURL %>" method="get"> <input name="search" value="<%= strSearch %>" /> <p> <p><B>Enter a second key word you want to search for or % in the text box below</B></p> <p></p> <input name="search1" value="<%= strSearch1 %>" /> <p> <p><B>Enter a third key word you want to search for or % in the text box below</B></p> <p></p> <input name="search2" value="<%= strSearch2 %>" /> <p> <input type="submit" /> </p> </form> <p></p> For the response.write statement, it appears it only captures the first keyword and ignores the other 2 keywords. Here is the response.write code ... Code:
Response.Write "<table border=1 cellspacing=2>"
Response.Write ("<tr>")
Response.Write ("<td>" & "<B>" & "Resume: " & "</B>" & "</td>")
Response.Write ("<td>" & rs("resume_doc") & "</td>")
Response.Write ("</tr>")
Is my response.write code incorrect? I believe my sql is correct. Can someone help me out here please? Thanks! |
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > Multiple keyword search on one database field |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|