Hi,
I've created a search page that pulls name details from an Access database. Originally the search took the user to a results page that I created but I've been asked to incorporate the results into the search.asp page itself. My code is below, but it causes all the names in the database to appear automatically. How can I stop this?
Regards,
Tazzer
<HTML>
<HEAD>
<TITLE>INI Intranet : Directory Search</TITLE>
</HEAD>
<BODY bgColor=#e0e0e0>
<div align="center">
<p><IMG src="title.gif"></p>
<font face=Verdana size=1 colour="73734d"><b>To search for a staff member's phone number<br> enter the <font SIZE=2 color="red">first name</font>
into the first field and<br> the <font size=2 color="red">surname</font> into the second field, then<br> click on the <font SIZE=2 color="red">Search button.</font>
Alternatively,<br> you can enter either a first name or surname only,<br> or even just the first few letters of a name.</b></font>
</div>
<p> </p>
<table align="center">
<TBODY>
<tr>
<form name="frmInternalDirectory" method="post" action="search1.asp">
<td><input name="txtFirstName" width="20" ><input name="txtSurname" width="20" ></td>
<td align="middle"><input type="submit" value="Search"></td>
</form>
</TBODY>
</table>
<table align="center"><tr></tr><td>
<font face=Verdana size=1>For any queries or additions required to the directory contact HR Facilities Management<br>
at <a href="mailto:Valerie.Warwick; Patrick.Bogan@investi.com">Chichester Street</a>, <a href="mailto:Molly.Vannan@investi.com"> Upper Galwally</a> or
<a href="mailto:Oliver.Corr@investi.com">Lisburn</a> or for technical problems contact the<br> <a href="mailto:helpdesk@investi.com">ICT eBusiness Internal team</a>.</font>
</td></tr>
</table>
</BODY>
</html>
<HTML>
<HEAD>
<TITLE>INI Intranet : Result</TITLE>
</HEAD>
<BODY bgcolor=#e0e0e0>
<%dim conn, rs
set conn = Server.CreateObject("ADODB.Connection"
conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Microsoft Site Server\Data\Publishing\ininet\TelDir\directory.mdb;Persist Security Info=False"
sql = "SELECT * FROM tblInternalDirectory WHERE strFirstName LIKE '"
sql = sql & Request.Form("txtFirstName" & "%' AND"
sql = sql & " strLastName LIKE '" & Request.Form("txtSurname" & "%'" & "ORDER BY strLastName ASC"
set rs = conn.execute(sql)
'if a non-existent recordset is entered this reply will be shown
if rs.BOF and rs.EOF then
Response.Write "<font face=Verdana size=1><b>Sorry there is no data entered for this person. Please try again.</b></font>"
else
'response.write sql
Response.Write "<p>"
Response.Write "<p> "
Response.Write "<TABLE BORDER=0 BORDERCOLOUR=73734d align=center cellpadding=5>"
Response.Write "<TR>"
Response.Write "<td><b><font face=Verdana size=1>First Name</b></td>"
Response.Write "<td><b><font face=Verdana size=1>Surname</b></td>"
Response.Write "<td><b><font face=Verdana size=1>Department</b></td>"
Response.Write "<td><b><font face=Verdana size=1>Extension/ Speedial</b></td>"
Response.Write "<td><b><font face=Verdana size=1>Direct Line</b></td>"
Response.Write "<td><b><font face=Verdana size=1>Mobile</b></td>"
Response.Write "<td><b><font face=Verdana size=1>Location</b></td>"
Response.Write "</tr>"
Do until rs.EOF
response.write "<TR>"
response.write "<TD><font face=Verdana size=1 color=red>" & rs("strFirstName" & "</TD>"
response.write "<TD><font face=Verdana size=1 color=red>" & rs("strLastName" & "</TD>"
response.write "<TD><font face=Verdana size=1>" & rs("strDepartment" & "</TD>"
response.write "<TD><font face=Verdana size=1>" & rs("intExtension" & "</TD>"
response.write "<TD><font face=Verdana size=1>" & rs("intDirect" & "</TD>"
response.write "<TD><font face=Verdana size=1>" & rs("intMobile" & "</TD>"
response.write "<TD><font face=Verdana size=1>" & rs("strRegion" & "</TD>"
response.write "</TR></font>"
rs.movenext
Loop
response.write "</TABLE>"
end if
rs.close
conn.close
set rs = nothing
set conn = nothing
%>
</BODY>
</HTML>
I've created a search page that pulls name details from an Access database. Originally the search took the user to a results page that I created but I've been asked to incorporate the results into the search.asp page itself. My code is below, but it causes all the names in the database to appear automatically. How can I stop this?
Regards,
Tazzer
<HTML>
<HEAD>
<TITLE>INI Intranet : Directory Search</TITLE>
</HEAD>
<BODY bgColor=#e0e0e0>
<div align="center">
<p><IMG src="title.gif"></p>
<font face=Verdana size=1 colour="73734d"><b>To search for a staff member's phone number<br> enter the <font SIZE=2 color="red">first name</font>
into the first field and<br> the <font size=2 color="red">surname</font> into the second field, then<br> click on the <font SIZE=2 color="red">Search button.</font>
Alternatively,<br> you can enter either a first name or surname only,<br> or even just the first few letters of a name.</b></font>
</div>
<p> </p>
<table align="center">
<TBODY>
<tr>
<form name="frmInternalDirectory" method="post" action="search1.asp">
<td><input name="txtFirstName" width="20" ><input name="txtSurname" width="20" ></td>
<td align="middle"><input type="submit" value="Search"></td>
</form>
</TBODY>
</table>
<table align="center"><tr></tr><td>
<font face=Verdana size=1>For any queries or additions required to the directory contact HR Facilities Management<br>
at <a href="mailto:Valerie.Warwick; Patrick.Bogan@investi.com">Chichester Street</a>, <a href="mailto:Molly.Vannan@investi.com"> Upper Galwally</a> or
<a href="mailto:Oliver.Corr@investi.com">Lisburn</a> or for technical problems contact the<br> <a href="mailto:helpdesk@investi.com">ICT eBusiness Internal team</a>.</font>
</td></tr>
</table>
</BODY>
</html>
<HTML>
<HEAD>
<TITLE>INI Intranet : Result</TITLE>
</HEAD>
<BODY bgcolor=#e0e0e0>
<%dim conn, rs
set conn = Server.CreateObject("ADODB.Connection"
conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Microsoft Site Server\Data\Publishing\ininet\TelDir\directory.mdb;Persist Security Info=False"
sql = "SELECT * FROM tblInternalDirectory WHERE strFirstName LIKE '"
sql = sql & Request.Form("txtFirstName" & "%' AND"
sql = sql & " strLastName LIKE '" & Request.Form("txtSurname" & "%'" & "ORDER BY strLastName ASC"
set rs = conn.execute(sql)
'if a non-existent recordset is entered this reply will be shown
if rs.BOF and rs.EOF then
Response.Write "<font face=Verdana size=1><b>Sorry there is no data entered for this person. Please try again.</b></font>"
else
'response.write sql
Response.Write "<p>"
Response.Write "<p> "
Response.Write "<TABLE BORDER=0 BORDERCOLOUR=73734d align=center cellpadding=5>"
Response.Write "<TR>"
Response.Write "<td><b><font face=Verdana size=1>First Name</b></td>"
Response.Write "<td><b><font face=Verdana size=1>Surname</b></td>"
Response.Write "<td><b><font face=Verdana size=1>Department</b></td>"
Response.Write "<td><b><font face=Verdana size=1>Extension/ Speedial</b></td>"
Response.Write "<td><b><font face=Verdana size=1>Direct Line</b></td>"
Response.Write "<td><b><font face=Verdana size=1>Mobile</b></td>"
Response.Write "<td><b><font face=Verdana size=1>Location</b></td>"
Response.Write "</tr>"
Do until rs.EOF
response.write "<TR>"
response.write "<TD><font face=Verdana size=1 color=red>" & rs("strFirstName" & "</TD>"
response.write "<TD><font face=Verdana size=1 color=red>" & rs("strLastName" & "</TD>"
response.write "<TD><font face=Verdana size=1>" & rs("strDepartment" & "</TD>"
response.write "<TD><font face=Verdana size=1>" & rs("intExtension" & "</TD>"
response.write "<TD><font face=Verdana size=1>" & rs("intDirect" & "</TD>"
response.write "<TD><font face=Verdana size=1>" & rs("intMobile" & "</TD>"
response.write "<TD><font face=Verdana size=1>" & rs("strRegion" & "</TD>"
response.write "</TR></font>"
rs.movenext
Loop
response.write "</TABLE>"
end if
rs.close
conn.close
set rs = nothing
set conn = nothing
%>
</BODY>
</HTML>