0

这是 search-process.asp 文件,我有一个带有搜索框的主页,该搜索框链接到该文件并使用搜索词来搜索我的数据库。

<!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>&nbsp;<b>lastname</b></td><td>&nbsp;</td>
        <td><b>Usr_id</b></td><td><b>firstname</b></td><td>&nbsp;<b>lastname</b></td><td>&nbsp;</td>
    </tr>
<% counter=0 %>
    <%Do While Not userRs.EOF
    counter=counter+1
if ((counter mod 2)= 1) Then%>
        <tr>
            <td>
                <%=userRs("usr_id") & "&nbsp;"%>
            </td>
            <td>

                <%=userRs("usr_firstname") %>
            </td>
            <td>
                <%=userRs("usr_lastname") %>
            </td>

    <%else%>


            <td>
                <!-- display the name of the mountain -->
                <%=userRs("usr_id") & "&nbsp;"%>
            </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>&nbsp;</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>

我收到此错误,不确定是 SQL 还是 ASP

ADODB.Recordset error '800a0bb9' 参数类型错误、超出可接受范围或相互冲突。

/student/s0190204/part2/search-process.asp,第 17 行

4

2 回答 2

2

您是否包括了adOpenkeyset, AdLockOptimistic等的定义...它通常在一个名为 adovbs.inc 的文件中,但您可以将它们添加到页面中的其他包含文件中。

于 2013-11-06T04:45:38.033 回答
1

未终止的字符串常量可能由搜索输入中的撇号引起。这是可以通过使用查询参数解决的众多问题之一。

于 2013-11-05T13:01:25.487 回答