Hi all,
I've got the following (asp) code for a search function but it doesn't seem to be linking to the database (Access).
I've tested it wiht names that definately exist within the database but it's not retuning any records.
This is the form the user has to fill out:
<Form method=post action=searchemployees.asp>
<p class=intro>Employee Surname:</p>
<p class=links>
<input type="text" name="StaffSurname">
<br>
<input type="submit" value="Search">
</form>
And this is the asp page it links to:
<%@ Language=VBScript %>
<html>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<head>
<title>EmployeeSearch</title>
</head>
<body>
<p class=heading>Employee Details</p>
%>
<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
surName = Request.QueryString("StaffSurname")
Call conn.Open(Server.Mappath("FinalProject.mdb"))
strSql="SELECT StaffID FROM TblStaff WHERE StaffSurname = '" & surName & "';"
Set rs = Conn.Execute(strSql)
if rs.eof Then
Response.write("No records Returned")
end if
do until rs.eof
Response.write(rs("StaffID"))
rs.movenext
loop
Conn.Close
%>
Any ideas?
Thanks,
Lx
I've got the following (asp) code for a search function but it doesn't seem to be linking to the database (Access).
I've tested it wiht names that definately exist within the database but it's not retuning any records.
This is the form the user has to fill out:
<Form method=post action=searchemployees.asp>
<p class=intro>Employee Surname:</p>
<p class=links>
<input type="text" name="StaffSurname">
<br>
<input type="submit" value="Search">
</form>
And this is the asp page it links to:
<%@ Language=VBScript %>
<html>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<head>
<title>EmployeeSearch</title>
</head>
<body>
<p class=heading>Employee Details</p>
%>
<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
surName = Request.QueryString("StaffSurname")
Call conn.Open(Server.Mappath("FinalProject.mdb"))
strSql="SELECT StaffID FROM TblStaff WHERE StaffSurname = '" & surName & "';"
Set rs = Conn.Execute(strSql)
if rs.eof Then
Response.write("No records Returned")
end if
do until rs.eof
Response.write(rs("StaffID"))
rs.movenext
loop
Conn.Close
%>
Any ideas?
Thanks,
Lx