|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#31
|
||||
|
||||
|
Your query looks fine to me.
What happens when you run this query in your database's query runner?? Also, i just realized that Access uses * as wildcard in Like rather than % But i am not too sure about Access version. Have a look at this link and see if it makes any sense. http://msdn.microsoft.com/en-us/lib...fice.10%29.aspx Other links that might help http://www.techonthenet.com/access/queries/like.php http://articles.techrepublic.com.co...11-6154704.html |
|
#32
|
||||
|
||||
|
--> Moved to ASP Forum, I think you will get a better response here.
Firstly, I would recommend that you pass the values in the Form collection instead of the querystring, use the POST method instead of GET. Also, I cannot see where you are assigning your Request values to the variables. Finally, I would be inclined to only append the conditions to the query if the user has entered a keyword that way you wouldn't have to get the user to enter a wildcard, try something like this: Code:
<!--Heres the form--> <form action="<%= strURL %>" method="post"> <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> Then your sql would look like: Code:
sql = "SELECT * FROM [RSA_Candidates] WHERE 1 = 1 "
If Len(Trim(Request.Form("strSearch"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch"), "'", "''") & "%' "
If Len(Trim(Request.Form("strSearch1"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch1"), "'", "''") & "%' "
If Len(Trim(Request.Form("strSearch2"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch2"), "'", "''") & "%' "
sql = sql & " ORDER BY lastname;"
With regards displaying the details, there is a known issue whereby you can only display the contents of your memo field once, I recommend that you assign the value to a variable, you can then display this whenever you want: Code:
If rs.EOF <> True Then
Response.Write("<table border=1 cellspacing=2><tr><td colspan=""2"">Results:</td></tr>")
While NOT rs.EOF
Dim memoVal
memoVal = rs.Fields("resume_doc")
Response.Write("<tr><td><B>Resume:</B></td><td>" & memoVal & "</td></tr>")
rs.MoveNext
Wend
Response.Write("</table>")
Else
Response.Write("Sorry, no records!!")
End If
|
|
#33
|
||||
|
||||
|
Threads Merged. Please refrain from cross posting, there should only be one active thread per topic. As well as keeing all related content in the same place, it is really frustrating for people like me who have just spent 10 minutes answering your question only to find that it has already been answered elsewhere!!
|
|
#34
|
|||
|
|||
|
I'm using the GET method because the user takes the results from this query and may do some updates to other fields on the records returned from the query.
I used the variable as suggested and entered 3 keywords in the form. After submitting the form, the page did not display. Not sure what went wrong here. Being I'm not very familar with asp, I believe it is a syntax issue. I followed what you were doing in your reply. Would you kindly take a look at my code and explain what I have wrong? I'll provide all the code here so you can see what I'm trying to do. Thank you for your help.. Here's the code ... 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
strSearch = Request.QueryString("search")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open("RSA_262093")
%>
<%
'************************************************* ****************************
' HIGHLIGHT function will search text for a specific string
' When string is found it will be surrounded by supplied strings
'
' NOTE: Unfortunately Replace() function does not preserve the original case
' of the found string. This function does.
'
' Parameters:
' strText - string to search in
' strFind - string to look for
' strBefore - string to insert before the strFind
' strAfter - string to insert after the strFind
'
' Example:
' This will make all the instances of the word "the" bold
'
' Response.Write Highlight(strSomeText, "the", "<b>", "</b>")
'
Function Highlight(strText, strFind, strBefore, strAfter)
Dim nPos
Dim nLen
Dim nLenAll
nLen = Len(strFind)
nLenAll = nLen + Len(strBefore) + Len(strAfter) + 1
Highlight = strText
If nLen > 0 And Len(Highlight) > 0 Then
nPos = InStr(1, Highlight, strFind, 1)
Do While nPos > 0
Highlight = Left(Highlight, nPos - 1) & _
strBefore & Mid(Highlight, nPos, nLen) & strAfter & _
Mid(Highlight, nPos + nLen)
nPos = InStr(nPos + nLenAll, Highlight, strFind, 1)
Loop
End If
End Function
'************************************************* ****************************
%>
<html>
<body bgcolor="#FFFFFF">
<p><B>Search and/or Update a Candidates' Record by the Resume Document field</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 1 = 1 "
If Len(Trim(Request.Form("strSearch"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch"), "'",
"''") & "%' "
If Len(Trim(Request.Form("strSearch1"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch1"), "'",
"''") & "%' "
If Len(Trim(Request.Form("strSearch2"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch2"), "'",
"''") & "%' "
sql = sql & " ORDER BY lastname;"
rs.Open sql, conn, adOpenForwardOnly, adLockReadOnly, adCmdText
%>
<%
IF not Rs.EOF then
Do While not Rs.EOF
Dim memoVal
memoVal = rs.Fields("resume_doc")
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>" & memoVal & "</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>
|
|
#35
|
|||
|
|||
|
I posted the sql to another thread to ensure that wasn't the issue and it isn't.
I still can't get this to work. I appreciate your time spent on this. Just need to get it to work now. Please review my last reply and advise what is wrong with the syntax. Thanks again |
|
#36
|
||||
|
||||
|
Quote:
I'm not sure I understand what you mean by this. IMO it is better to use the POST method instead of GET because it means that your values will be passed via the form collection and wont be visible in the addressbar. You can grab them in much the same way, just use Request or Request.Form instead of Request.Querystring!! If you need to access these values on another page you could put the values into session variables which can be accessed on any page, eg: Code:
Session("search1") = Request.Form("strSearch1")
Quote:
Did it give you an error or did the page just appear blank? |
|
#37
|
|||
|
|||
|
I tried using the post method and only the form appears.
When I enter the three keywords and press enter, the form just reappears with blanks in the text box. I also added the session variables but I'm not sure how to use them. Here's the code with the latest changes ..... 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
strSearch = Request.QueryString("search")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open("RSA_262093")
%>
<%
'************************************************* ****************************
' HIGHLIGHT function will search text for a specific string
' When string is found it will be surrounded by supplied strings
'
' NOTE: Unfortunately Replace() function does not preserve the original case
' of the found string. This function does.
'
' Parameters:
' strText - string to search in
' strFind - string to look for
' strBefore - string to insert before the strFind
' strAfter - string to insert after the strFind
'
' Example:
' This will make all the instances of the word "the" bold
'
' Response.Write Highlight(strSomeText, "the", "<b>", "</b>")
'
Function Highlight(strText, strFind, strBefore, strAfter)
Dim nPos
Dim nLen
Dim nLenAll
nLen = Len(strFind)
nLenAll = nLen + Len(strBefore) + Len(strAfter) + 1
Highlight = strText
If nLen > 0 And Len(Highlight) > 0 Then
nPos = InStr(1, Highlight, strFind, 1)
Do While nPos > 0
Highlight = Left(Highlight, nPos - 1) & _
strBefore & Mid(Highlight, nPos, nLen) & strAfter & _
Mid(Highlight, nPos + nLen)
nPos = InStr(nPos + nLenAll, Highlight, strFind, 1)
Loop
End If
End Function
'************************************************* ****************************
%>
<html>
<body bgcolor="#FFFFFF">
<p><B>Search and/or Update a Candidates' Record by the Resume Document field</B></p>
<p></p>
<form action="<%= strURL %>" method="post">
<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 1 = 1 "
If Len(Trim(Request.Form("strSearch"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch"), "'",
"''") & "%' "
If Len(Trim(Request.Form("strSearch1"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch1"), "'",
"''") & "%' "
If Len(Trim(Request.Form("strSearch2"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch2"), "'",
"''") & "%' "
sql = sql & " ORDER BY lastname;"
rs.Open sql, conn, adOpenForwardOnly, adLockReadOnly, adCmdText
%>
<%
IF not Rs.EOF then
Do While not Rs.EOF
Dim memoVal
memoVal = rs.Fields("resume_doc")
Session("search") = Request.Form("strSearch")
Session("search1") = Request.Form("strSearch1")
Session("search2") = Request.Form("strSearch2")
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>" & memoVal & "</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>
The goal here is to get all the records that have in their resume_doc field, the 3 keywords the user entered. Thanks for helping me with this. I appreciate it. |
|
#38
|
||||
|
||||
|
You have changed the method to post but you will only drop into the code if strSearch contains a value, change the highlighted line:
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
strSearch = Request.Form("search")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open("RSA_262093")
'etc...
%>
|
|
#39
|
|||
|
|||
|
I made the change you suggested. The form is displayed and I entered 3 keywords. I submitted the form and after a minute or so received an http 500 Internal Server Error --
The error in Firefox is Quote:
How could I increase the response buffer? Here's the code as it is now ... 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
strSearch = Request.Form("search")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open("RSA_262093")
%>
<%
'************************************************* ****************************
' HIGHLIGHT function will search text for a specific string
' When string is found it will be surrounded by supplied strings
'
' NOTE: Unfortunately Replace() function does not preserve the original case
' of the found string. This function does.
'
' Parameters:
' strText - string to search in
' strFind - string to look for
' strBefore - string to insert before the strFind
' strAfter - string to insert after the strFind
'
' Example:
' This will make all the instances of the word "the" bold
'
' Response.Write Highlight(strSomeText, "the", "<b>", "</b>")
'
Function Highlight(strText, strFind, strBefore, strAfter)
Dim nPos
Dim nLen
Dim nLenAll
nLen = Len(strFind)
nLenAll = nLen + Len(strBefore) + Len(strAfter) + 1
Highlight = strText
If nLen > 0 And Len(Highlight) > 0 Then
nPos = InStr(1, Highlight, strFind, 1)
Do While nPos > 0
Highlight = Left(Highlight, nPos - 1) & _
strBefore & Mid(Highlight, nPos, nLen) & strAfter & _
Mid(Highlight, nPos + nLen)
nPos = InStr(nPos + nLenAll, Highlight, strFind, 1)
Loop
End If
End Function
'************************************************* ****************************
%>
<html>
<body bgcolor="#FFFFFF">
<p><B>Search and/or Update a Candidates' Record by the Resume Document field</B></p>
<p></p>
<form action="<%= strURL %>" method="post">
<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 1 = 1 "
If Len(Trim(Request.Form("strSearch"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch"), "'", "''") & "%' "
If Len(Trim(Request.Form("strSearch1"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch1"), "'", "''") & "%' "
If Len(Trim(Request.Form("strSearch2"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch2"), "'", "''") & "%' "
sql = sql & " ORDER BY lastname;"
rs.Open sql, conn, adOpenForwardOnly, adLockReadOnly, adCmdText
%>
<%
IF not Rs.EOF then
Do While not Rs.EOF
Dim memoVal
memoVal = rs.Fields("resume_doc")
Session("search") = Request.Form("strSearch")
Session("search1") = Request.Form("strSearch1")
Session("search2") = Request.Form("strSearch2")
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>" & memoVal & "</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 again for your help and time. I sincerely appreciate it.. |
|
#40
|
||||
|
||||
|
What does your sql statement contain, can you add the highlighted lines and post the result:
Code:
<%
If strSearch <> "" Then
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM [RSA_Candidates] WHERE 1 = 1 "
If Len(Trim(Request.Form("strSearch"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch"), "'", "''") & "%' "
If Len(Trim(Request.Form("strSearch1"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch1"), "'", "''") & "%' "
If Len(Trim(Request.Form("strSearch2"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch2"), "'", "''") & "%' "
sql = sql & " ORDER BY lastname;"
Response.Write(sql)
Response.End
rs.Open sql, conn, adOpenForwardOnly, adLockReadOnly, adCmdText
%>
<%
IF not Rs.EOF then
Do While not Rs.EOF
|
|
#41
|
|||
|
|||
|
I put the 2 lines of code in as requested.
This was the result Quote:
Here is the revised code with the 2 new lines added .. 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
strSearch = Request.Form("search")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open("RSA_262093")
%>
<%
'************************************************* ****************************
' HIGHLIGHT function will search text for a specific string
' When string is found it will be surrounded by supplied strings
'
' NOTE: Unfortunately Replace() function does not preserve the original case
' of the found string. This function does.
'
' Parameters:
' strText - string to search in
' strFind - string to look for
' strBefore - string to insert before the strFind
' strAfter - string to insert after the strFind
'
' Example:
' This will make all the instances of the word "the" bold
'
' Response.Write Highlight(strSomeText, "the", "<b>", "</b>")
'
Function Highlight(strText, strFind, strBefore, strAfter)
Dim nPos
Dim nLen
Dim nLenAll
nLen = Len(strFind)
nLenAll = nLen + Len(strBefore) + Len(strAfter) + 1
Highlight = strText
If nLen > 0 And Len(Highlight) > 0 Then
nPos = InStr(1, Highlight, strFind, 1)
Do While nPos > 0
Highlight = Left(Highlight, nPos - 1) & _
strBefore & Mid(Highlight, nPos, nLen) & strAfter & _
Mid(Highlight, nPos + nLen)
nPos = InStr(nPos + nLenAll, Highlight, strFind, 1)
Loop
End If
End Function
'************************************************* ****************************
%>
<html>
<body bgcolor="#FFFFFF">
<p><B>Search and/or Update a Candidates' Record by the Resume Document field</B></p>
<p></p>
<form action="<%= strURL %>" method="post">
<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 1 = 1 "
If Len(Trim(Request.Form("strSearch"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch"), "'", "''") & "%' "
If Len(Trim(Request.Form("strSearch1"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch1"), "'", "''") & "%' "
If Len(Trim(Request.Form("strSearch2"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch2"), "'", "''") & "%' "
sql = sql & " ORDER BY lastname;"
Response.Write(sql)
Response.End
rs.Open sql, conn, adOpenForwardOnly, adLockReadOnly, adCmdText
%>
<%
IF not Rs.EOF then
Do While not Rs.EOF
Dim memoVal
memoVal = rs.Fields("resume_doc")
Session("search") = Request.Form("strSearch")
Session("search1") = Request.Form("strSearch1")
Session("search2") = Request.Form("strSearch2")
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>" & memoVal & "</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>
|
|
#42
|
|||
|
|||
|
Quote:
Hi, Till sync comes in just check whether these values are being passed. Request.Form("strSearch") Request.Form("strSearch1") Request.Form("strSearch2") with something like <input name="strSearch">........ <input name="strSearch1">........ <input name="strSearch2">........ Thanx |
|
#43
|
|||
|
|||
|
I'm not really sure how to do this. I added this code and it's incorrect
Code:
Response.Write(sql) Response.Write(input name="strSearch") Response.Write(input name="strSearch1") Response.Write(input name="strSearch2") Response.End Can you tell me what the code should be to display the values the user input and where this code should go? Here's my code as it is now .. 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
strSearch = Request.Form("search")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open("RSA_262093")
%>
<%
'************************************************* ****************************
' HIGHLIGHT function will search text for a specific string
' When string is found it will be surrounded by supplied strings
'
' NOTE: Unfortunately Replace() function does not preserve the original case
' of the found string. This function does.
'
' Parameters:
' strText - string to search in
' strFind - string to look for
' strBefore - string to insert before the strFind
' strAfter - string to insert after the strFind
'
' Example:
' This will make all the instances of the word "the" bold
'
' Response.Write Highlight(strSomeText, "the", "<b>", "</b>")
'
Function Highlight(strText, strFind, strBefore, strAfter)
Dim nPos
Dim nLen
Dim nLenAll
nLen = Len(strFind)
nLenAll = nLen + Len(strBefore) + Len(strAfter) + 1
Highlight = strText
If nLen > 0 And Len(Highlight) > 0 Then
nPos = InStr(1, Highlight, strFind, 1)
Do While nPos > 0
Highlight = Left(Highlight, nPos - 1) & _
strBefore & Mid(Highlight, nPos, nLen) & strAfter & _
Mid(Highlight, nPos + nLen)
nPos = InStr(nPos + nLenAll, Highlight, strFind, 1)
Loop
End If
End Function
'************************************************* ****************************
%>
<html>
<body bgcolor="#FFFFFF">
<p><B>Search and/or Update a Candidates' Record by the Resume Document field</B></p>
<p></p>
<form action="<%= strURL %>" method="post">
<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 1 = 1 "
If Len(Trim(Request.Form("strSearch"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch"), "'",
"''") & "%' "
If Len(Trim(Request.Form("strSearch1"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch1"), "'",
"''") & "%' "
If Len(Trim(Request.Form("strSearch2"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("strSearch2"), "'",
"''") & "%' "
sql = sql & " ORDER BY lastname;"
Response.Write(sql)
Response.Write(input name="strSearch")
Response.Write(input name="strSearch1")
Response.Write(input name="strSearch2")
Response.End
rs.Open sql, conn, adOpenForwardOnly, adLockReadOnly, adCmdText
%>
<%
IF not Rs.EOF then
Do While not Rs.EOF
Dim memoVal
memoVal = rs.Fields("resume_doc")
Session("search") = Request.Form("strSearch")
Session("search1") = Request.Form("strSearch1")
Session("search2") = Request.Form("strSearch2")
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>" & memoVal & "</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>
I apologize but I'm not that familiar with asp. Thank you for your help and patience. I'm pretty frustrated with this... Thanks! |
|
#44
|
||||
|
||||
|
You need to change the lines as per my highlights, I had set it up to look for strSearch, strSearch2 etc, but it should be search, search1 and search2:
Code:
If Len(Trim(Request.Form("search"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("search"), "'", "''") & "%' "
If Len(Trim(Request.Form("search1"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("search1"), "'", "''") & "%' "
If Len(Trim(Request.Form("search2"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("search2"), "'", "''") & "%' "
sql = sql & " ORDER BY lastname;"
|
|
#45
|
|||
|
|||
|
I made the change and entered keywords html, unix and sql.
Yes the code is picking up the keywords. Here's what appeared on the screen.. Quote:
Here's the code now ... 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
strSearch = Request.Form("search")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open("RSA_262093")
%>
<%
'************************************************* ****************************
' HIGHLIGHT function will search text for a specific string
' When string is found it will be surrounded by supplied strings
'
' NOTE: Unfortunately Replace() function does not preserve the original case
' of the found string. This function does.
'
' Parameters:
' strText - string to search in
' strFind - string to look for
' strBefore - string to insert before the strFind
' strAfter - string to insert after the strFind
'
' Example:
' This will make all the instances of the word "the" bold
'
' Response.Write Highlight(strSomeText, "the", "<b>", "</b>")
'
Function Highlight(strText, strFind, strBefore, strAfter)
Dim nPos
Dim nLen
Dim nLenAll
nLen = Len(strFind)
nLenAll = nLen + Len(strBefore) + Len(strAfter) + 1
Highlight = strText
If nLen > 0 And Len(Highlight) > 0 Then
nPos = InStr(1, Highlight, strFind, 1)
Do While nPos > 0
Highlight = Left(Highlight, nPos - 1) & _
strBefore & Mid(Highlight, nPos, nLen) & strAfter & _
Mid(Highlight, nPos + nLen)
nPos = InStr(nPos + nLenAll, Highlight, strFind, 1)
Loop
End If
End Function
'************************************************* ****************************
%>
<html>
<body bgcolor="#FFFFFF">
<p><B>Search and/or Update a Candidates' Record by the Resume Document field</B></p>
<p></p>
<form action="<%= strURL %>" method="post">
<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 1 = 1 "
If Len(Trim(Request.Form("search"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("search"), "'", "''") &
"%' "
If Len(Trim(Request.Form("search1"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("search1"), "'", "''")
& "%' "
If Len(Trim(Request.Form("search2"))) > 0 Then sql = sql & "AND resume_doc LIKE '%"& Replace(Request.Form("search2"), "'", "''")
& "%' "
sql = sql & " ORDER BY lastname;"
Response.Write(sql)
Response.End
rs.Open sql, conn, adOpenForwardOnly, adLockReadOnly, adCmdText
%>
<%
IF not Rs.EOF then
Do While not Rs.EOF
Dim memoVal
memoVal = rs.Fields("resume_doc")
Session("search") = Request.Form("strSearch")
Session("search1") = Request.Form("strSearch1")
Session("search2") = Request.Form("strSearch2")
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>" & memoVal & "</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>
I'm thinking the issue must be in the response.write statement for the resume_doc field. Correct? |
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > Multiple keyword search on one database field |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|