Reputation:
This is the search-process.asp file, I have a main page with a search box that links to this and uses search terms to search my database.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>UNIBOOK - Your facebook alternative - but with no adverts..!</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/unibookStyle.css" />
<%@ Language=VBScript %>
<%
set conx=server.CreateObject("adodb.connection")
conx.Provider="Microsoft.ACE.OLEDB.12.0"
conx.Open Server.Mappath("db/unibookv2.mdb")
set userRs=server.CreateObject("adodb.recordset")
userRs.Open "SELECT * FROM ubuser WHERE usr_firstname LIKE '%" & request("searchinput") & "%' OR usr_lastname LIKE '%" & request("searchinput") & "%' ORDER BY '%" & request("orderlist") & "%' ",conx, adOpenkeyset, AdLockOptimistic
%>
<!-- #include FILE="include/header.asp") -->
<div id="container"><!-- start container -->
<h2>USER DATABASE</h2>
<!-- start of dynamic html page -->
<h2>ASP Search Results ordered by : <%=request("orderlist")%></h2>
<%="<b>Search string:</b> " & searchinput & "<br />"%>
<hr align="left" width="658" />
<%if NOT userRs.EOF Then%>
<!-- start of html table -->
<table border="0" width="758" cellspacing="0" cellpadding="3">
<!-- create the first (heading) row in standard HTML -->
<tr class="tableheading">
<td><b>Usr_id</b></td><td><b>firstname</b></td><td> <b>lastname</b></td><td> </td>
<td><b>Usr_id</b></td><td><b>firstname</b></td><td> <b>lastname</b></td><td> </td>
</tr>
<% counter=0 %>
<%Do While Not userRs.EOF
counter=counter+1
if ((counter mod 2)= 1) Then%>
<tr>
<td>
<%=userRs("usr_id") & " "%>
</td>
<td>
<%=userRs("usr_firstname") %>
</td>
<td>
<%=userRs("usr_lastname") %>
</td>
<%else%>
<td>
<!-- display the name of the mountain -->
<%=userRs("usr_id") & " "%>
</td>
<td>
<!-- some comment here -->
<%=userRs("usr_firstname") %>
</td>
<td>
<%=userRs("usr_lastname") %>
</td>
</tr>
<%end if%>
<%userRs.MoveNext
LOOP%>
</table>
<%else%>
<!-- remember to provide a message if the search is not successful -->
<h3>Sorry your search was unsuccessful, please retry</h3>
<%end if%>
<p> </p>
<hr align="left" width="658">
<input type="button" value="< Back to Search Page" OnClick="top.location='default.asp'">
<!-- #include FILE="include/sidebar.asp") -->
</div><!-- end main page content -->
<%
' tidy up any ASP objects used to free web server resources...
userRs.close
set userRs=nothing
set conx=nothing
%>
<!-- #include FILE="include/footer.asp") -->
</body>
</html>
I am getting this error and am not sure if it is the SQL or ASP
ADODB.Recordset error '800a0bb9' Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/student/s0190204/part2/search-process.asp, line 17
Upvotes: 0
Views: 13791
Reputation: 2442
Are you including the definitions for adOpenkeyset, AdLockOptimistic
etc... Its usually in a file called adovbs.inc, but you could add them to other include files in your page..
Upvotes: 2
Reputation: 20804
An unterminated string constant can be caused by an apostrophe in the search input. That is one of the many problems that can be solved by using query parameters.
Upvotes: 1