回 帖 发 新 帖 刷新版面

主题:[讨论]新手ADODB.Recordset (0x800A0BB9)问题,请大家帮忙

错误类型:
ADODB.Recordset (0x800A0BB9)
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
/cx.asp, 第 57 行

---conn.asp-----
<% 
dim conn
set conn=server.createobject("adodb.connection")  
conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("xxgl.mdb")
function closeconn()
conn.close()
set conn=nothing
end function
 %>
-------cx.asp------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body,td,th {
    font-size: 12px;
    color: #333333;
}
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
.STYLE1 {color: #FF0000}
-->
</style></head>

<body>
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><img src="images/yd.gif" width="778" height="150" /></td>
  </tr>
  <tr>
    <td height="20" align="right" bgcolor="#B2C6F6">药店信息管理&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="30" align="center" valign="middle"><span class="STYLE1">查 询 结 果</span></td>
      </tr>
      <tr>
        <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC" style=" border-bottom:1px #CCCCCC dotted;border-top:1px #CCCCCC dotted;border-left:1px #CCCCCC dotted;border-right:1px #CCCCCC dotted">
          <tr>
            <td width="63" align="center" bgcolor="#FFFFFF">ID</td>
            <td width="63" align="center" bgcolor="#FFFFFF">编号</td>
            <td width="333" height="30" align="center" bgcolor="#FFFFFF">药店名称</td>
            <td width="124" align="center" bgcolor="#FFFFFF">用户名</td>
            <td width="124" align="center" bgcolor="#FFFFFF">密码</td>
            <td width="126" align="center" bgcolor="#FFFFFF">注册码</td>
            </tr>
          <% 
          cx=request.Form("cx")
          sel=request.Form("sel")
          if sel="bianhao" then
          sql="select * from yd where yd_id like'%"&cx&"%'"
          end if
          if sel="mingcheng" then
          sql="select * from yd where yd_name like'%"&cx&"%'"
          end if
          set rs=server.CreateObject("adodb.recordset")
             rs.open sql,conn,2,3
             if rs.recordcount<0 then
             response.Write "对不起没有找的相关的内容!"
             else
             do while not rs.eof
           %>
          <tr>
            <td width="78" align="center" valign="middle" bgcolor="#FFFFFF"><%=rs("id")%></td>
            <td width="100" bgcolor="#FFFFFF"><%=rs("yd_id")%></td>
            <td width="350" height="20" bgcolor="#FFFFFF"><%=rs("yd_name")%></td>
            <td width="100" bgcolor="#FFFFFF"><%=rs("yd_username")%></td>
            <td width="100" bgcolor="#FFFFFF"><%=rs("yd_psw")%></td>
            <td width="150" bgcolor="#FFFFFF"><%=rs("yd_zcm")%></td>
            </tr>
          <% 
          rs.movenext
          loop
          
           %>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<%end if%>
</body>
</html>


请各位高手指点,看看错在那里了,我在网上看了好多关于此类的问题,还是没找到解决的方法,急啊``````

回复列表 (共8个回复)

沙发

57行是哪一行阿?
sql="select * from yd where yd_id like '%"&cx&"%'"
我估计问题在这里,你得yd_id是什么类型的字段阿?如果是int型是不能用like的。

板凳

提示: rs.open sql,conn,2,3 错误
yd_id 是药店编码 是文本类型``

ADODB.Recordset (0x800A0BB9)
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
/cx.asp, 第 57 行


浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; KuGooSoft; InfoPath.1) 

网页:
POST 19 ??? /cx.asp

POST Data:
cx=1250&sel=biaohao 

时间:
2007年4月1日, 10:01:34 


详细信息:

3 楼

rs.open sql,conn,1,1

4 楼


我改了,还是同样的错误```

5 楼

建议查一下sql语句是否正确,这种错误有可能是sql语句写错了,比如字段名或者表名写错了!或者你传的cx有问题。你可以一步步排除错误,比如先写一句不带where 条件的看看,然后cx指定一个值看看,逐步排除问题。

6 楼

like 与后面的单引号之间加个空格试试

7 楼


我把 cx=request.form("cx")改为cx=cstr(request.form("cx"))了
但是为什么加了
if sel="bianhao" then
sql="......"
end if
就不行啊``?
直接写、
sql="select * from yd where yd_name like'%"&cx&"%'"就行了啊``

8 楼

你看看sel获取到了值了没?有没有走到if语句里面?是不是没有满足条件,导致没有生成sql语句。
在 rs.open sql,conn,1,1 前面加一句 response.write "sql:" & sql 
看看sql语句是不是正确。

我来回复

您尚未登录,请登录后再回复。点此登录或注册