Reputation: 13
I am currently a student attempting to learn and understand ASP. I would like to apologize in advance for any obvious or silly mistakes that might be discovered. I have no knowledge or understanding of ASP. I will be grateful for any advice or solution provided.
My assignment: To use access database (2003 version of access) to create a doctor's list, in order to search for the doctor by name and/or zip code. I have created the doctor's list "Contacts. mdb" in access (2003), the html page with the form to allow for the search based on name and/or zip code of the doctor and the ASP page in order to retrieve the results based on the search criteria.
The error I receive: SELECT * FROM contacts where lastname like '%%'; Microsoft JET Database Engine error '80040e10'
No value given for one or more required parameters.
/HPA563/Spring2014/kpatha3/Dynamic/OBGYNASPcode.asp, line 21
My html form code:
<html>
<body>
<form id="form1" name="form1" method="post" action="OBGYNASPcode.asp">
<label>Doctor's last name:
<input type="text" name="searchTerm" />
</label>
<label>ZIP code:
<input type="text" name="locationTerm" />
</label>
<p>
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
</body>
</html>
ASP Code:
<html>
<head>
<title>OBGYN ASP Page</title>
</head>
<body bgcolor="white" text="black">
<%
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("contacts.mdb")
Set rsDoctors = Server.CreateObject("ADODB.Recordset")
if (request.form("locationTerm")="") then
strSQL = "SELECT * FROM contacts where lastname like '%" & request.form("searchTerm") & "%';"
else
strSQL = "SELECT * FROM contacts where lastname like '%" & request.form("searchTerm") & "%' and zipcode = " & request.form("locationTerm") &";"
end if
Response.Write strSQL
rsDoctors.Open strSQL, adoCon
Response.Write ("<table border='1' width='600'>")
Response.Write ("<tr><td><b>Name</b></td><td><b>Location</b></td></tr>")
Do While not rsDoctors.EOF
Response.Write ("<tr><td>")
Response.Write (rsDoctors("firstName") &" "& rsDoctors("lastName"))
Response.Write ("</td><td>")
Response.Write (rsDoctors("zipcode"))
Response.Write ("</td>")
rsDoctors.MoveNext
Loop
rsDoctors.Close
Set rsDoctors = Nothing
Set adoCon = Nothing
%>
</body>
</html>
If I am missing any information, please let me know.
Thank you!
Upvotes: 1
Views: 4812
Reputation: 180788
No value given for one or more required parameters.
SELECT * FROM contacts where lastname like '%%'
^^-------- Missing parameter here.
I'm guessing that no search term was entered.
Upvotes: 3