参数类型错误,超出可接受的范围,或彼此冲突

时间:2013-11-05 12:52:19

标签: sql asp-classic

这是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错误'800a0bb9'   参数类型错误,超出可接受的范围,或彼此冲突。

     

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

3 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:1)

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

答案 2 :(得分:-1)

我说你必须替换这个

& request("orderlist")",conx, adOpenkeyset, AdLockOptimistic

由此

& request("orderlist") & ",conx, adOpenkeyset, AdLockOptimistic"