提示:ADODB.Recordset (0x800A0BB9)

shanyajun 2009-07-29 09:46:38
<!--+++++++++++++++++++++++
index.ASP源码
+++++++++++++++++++++++ -->

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="inc/conn.asp" -->
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conn_STRING
Recordset1.Source = "SELECT * FROM pro_table"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="583" border="0" cellspacing="0" cellpadding="0">
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td width="140"><%=(Recordset1.Fields.Item("id").Value)%></td>
<td width="171"><%=(Recordset1.Fields.Item("proname").Value)%></td>
<td width="272"><%=(Recordset1.Fields.Item("simages").Value)%></td>
<td width="272"><a href="cart.asp?ProductID=<%=(Recordset1.Fields.Item("id").Value)%>&quantity=1">购买</a></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</table>
</body>
</html>
<%
Recordset1.Close()
%>


运行提示错误:
错误类型:
ADODB.Recordset (0x800A0BB9)
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
...全文
83 点赞 收藏 12
写回复
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
shanyajun 2009-07-29
[Quote=引用 10 楼 cpp2017 的回复:]
Set Recordset1.ActiveConnection =conn



[/Quote]修改了又提示:
Microsoft OLE DB Provider for SQL Server (0x80040E21)
无法支持要求的属性。
/OUNIQ/yn/gowu/index.asp, 第 14 行

第 14 行代码是: Recordset1.Open()
回复
net_yuhai 2009-07-29
Recordset1.ActiveConnection = MM_conn_STRING
换成
Set Recordset1.ActiveConnection = conn

MM_conn_STRING 不知哪弄来的。

回复
cpp2017 2009-07-29
Set Recordset1.ActiveConnection =conn


回复
toury 2009-07-29
Set Recordset1.ActiveConnection =conn
回复
shanyajun 2009-07-29
[Quote=引用 7 楼 cpp2017 的回复:]
把你的conn.asp贴出来.

[/Quote]四楼已经贴了,请大哥帮看下错在那了
回复
cpp2017 2009-07-29
把你的conn.asp贴出来.
回复
shanyajun 2009-07-29
数据库字段
表:pro_talbe:
id 产品编号
proname 产品名称
simages 产品小图
表o_rder:
id 订单编号
p_roid 产品编号
m_um 产品数量
d_time 订购时间
表co_table:
id 客户编号
nn_ame 客户姓名
tt_el 联系电话
ee_m_ail 客户邮箱

这是数据库
回复
shanyajun 2009-07-29
这是购物车页面,那为高手帮测试下,错在那?谢谢
<!-- +++++++++++++++++++++++++
下面是cart.asp的源码:
+++++++++++++++++++++ -->

<%@LANGUAGE="VBScript"%>
<!--#include file="inc/conn.asp" -->
<%
if not IsObject(session("cart")) then
Set session("cart")=CreateObject("Scripting.Dictionary")
end if
Set cart=session("cart")
productID=Cstr(request("productID"))
dim detail(1)
detail(0)=Int(request("quantity"))
if request("productID")<>"" then
if cart.Exists(productID) then
cart.Remove(productID)
end if
cart.add productID,detail
end if
keys=cart.keys
items=cart.items
set session("cart")=cart
%>

<HTML>
<HEAD>
<TITLE>Canbob Network</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK
href="index/index.css" type=text/css rel=stylesheet>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
</HEAD>
<BODY text=#000000 bgColor=#ffffff leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
<tr>
<td width="100%" valign="top"> <br>
<table border="2" width="100%" cellspacing="0" cellpadding="0" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" bgcolor="#D00000" height="1" align="center">
<tr bgcolor="#3399FF">
<td width="25%" align="center" height="19"><font color="#FFFFFF">商品名称</font></td>
<td width="25%" align="center" height="19"><font color="#FFFFFF">购买数量</font></td>
<td width="12%" align="center" height="19"><font color="#FFFFFF">更新</font></td>
<td width="13%" align="center" height="19"><font color="#FFFFFF">删除</font></td>
</tr>
<% For i = 0 To cart.Count -1 %>
<% Dim list__MMColParam
list__MMColParam = keys(i) %>
<% set list = Server.CreateObject("ADODB.Recordset")
list.ActiveConnection = MM_conn_STRING
list.Source = "SELECT * FROM pro_table WHERE id = " + Replace(list__MMColParam, "’", "’’") + ""
list.CursorType = 0
list.CursorLocation = 2
list.LockType = 3
list.Open()
%>
<form method="post" action="cart.asp" onSubmit="return checkform(this);"> ’更新产品数量用
<tr bgcolor="#ECECFF">
<td width="25%" align="center" height="1"><a href="detail.asp?productID=<%=keys(i)%>"><font color="#000077" ></font></a><%=(list.Fields.Item("proname").Value)%></td>
<td width="25%" align="center" height="1">
<input name="quantity" size=4 class="edit" value="<%=items(i)(0)%>">
<input type="hidden" name="productID" value="<%=keys(i)%>">
</td>
<td width="12%" align="center" height="1">
<input type="image" border="0" name="imageField" src="images/ref.gif" width="17" height="19">
</td>
<td width="13%" align="center" height="1"><a href="delcart.asp?productID=<%=keys(i)%>"><img src="images/del.gif" width="17" height="19" border="0"></a></td>
</tr>
</form>
<%
list.Close()
%>
<% next %>
<tr >
<td width="75%" bgcolor="#000000" align="center" height="1" colspan="2">
<p align="right"><font color="#FFFFFF">总价合计:</font>
</td>
<td width="25%" bgcolor="#000000" align="center" height="1" colspan="2"><font color="#FFFFFF">¥<%=price%></font></td>
</tr>
</table>
<p align="center"><b><a href="index.asp">继续选购</a> <a href="order.asp">付款</a></b>
</td>
</tr>
</table>
</BODY>
</HTML>
回复
shanyajun 2009-07-29
这是链接代码:
<%
'创建数据库链接
'On Error Resume Next
Const SqlUsername = "sa"
Const SqlPassword = ""
Const SqlDatabaseName = "gowu"
Const SqlLocalName = "(local)"
Dim Db,Conn,ConnStr
Sub OpenConn()
Dim ConnStr
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
ErrorInfo = Err.Description
err.Clear
Set Conn = Nothing
Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"" /><div style='font-size:12px;font-weight:bold;border:1px solid #006;padding:6px;background:#fcc'>服务器忙,请稍后重试</div>"
Response.End()
End If
End Sub


Sub CloseConn(AspObject)
AspObject.Close()
Set AspObject = Nothing
End Sub

Public Function SafeRequest(ParaName,ParaType)
'--- 传入参数 ---
'ParaName:参数名称-字符型
'ParaType:参数类型-数字型(1表示以上参数是数字,0表示以上参数为字符)
Dim Paravalue
Paravalue = Request(ParaName)
If Paravalue <> "" Then Paravalue = Trim(Paravalue)
If ParaType=1 then
'添加非空判断 Paravalue=replace(Paravalue,"-","")
If Paravalue="" then
'Response.write "参数" & ParaName & "不能为空!"
Exit Function
ElseIf Not IsNumeric(Paravalue) Then
Response.write "参数" & ParaName & "必须为数字型!"
Response.End()
End if
Else
Paravalue=replace(Paravalue,"'","")
Paravalue=replace(Paravalue,"%","")
End if
SafeRequest=Paravalue
End Function

'作用:信息反馈
'参数:类型,提示文字,跳转链接
Public Sub alertError(Types,errorStr,Url)
Response.Write("<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">")
Dim strMsg
strMsg = "系统提示:\n\n"& errorStr &"\n"
Select Case Types
Case 1
Response.Write("<script language=""javascript"">alert('"& strMsg &"');history.back();</script>")
Case 2
Response.Write("<script language=""javascript"">alert('"& strMsg &"');self.location='"& Url &"';</script>")
Case 3
Response.Write("<script language=""javascript"">alert('"& strMsg &"');window.close();</script>")
Case 4
Response.Write("<script language=""javascript"">alert('"& strMsg &"');</script>")
Case 5
Response.Write("<script language=""javascript"">alert('"& strMsg &"');top.location='"& Url &"';</script>")
Case 6
Response.Write("<script language=""javascript"">alert('"& strMsg &"');self.location.reload();</script>")
Case 7
Response.Write("<script language=""javascript"">top.location='"& Url &"';</script>")
Case 8
Response.Write("<script language=""javascript"">top.leftFrame.location.reload();alert('"& strMsg &"');self.location='"& Url &"';</script>")
Case 9
Response.Write("<script language=""javascript"">alert('"& strMsg &"');parent.location='"& Url &"';</script>")
Case 10
Response.Write("<script language=""javascript"">self.location='"& Url &"';</script>")
Case 11
Response.Write("<script language=""javascript"">alert('"& strMsg &"'); window.opener.location.reload(); window.close(); </script>")
Case 12
Response.Write("<script language=""javascript"">alert('"& strMsg &"'); window.close(); </script>")
Case 13
Response.Write("<script language=""javascript"">top.location.reload();</script>")
Case 14
Response.Write("<script language=""javascript"">parent.location.reload();</script>")
Case 15
Response.Write("<script language=""javascript"">parent.location=top.location.href;</script>")
Case Else
Response.Write("<script language=""javascript"">alert('"& strMsg &"');"& Url &";</script>")
End Select
Response.End()
End Sub

Call OpenConn()
%>
回复
cpp2017 2009-07-29
Set Recordset1.ActiveConnection = 你的连接对象
回复
shanyajun 2009-07-29
[Quote=引用 1 楼 cpp2017 的回复:]
Recordset1.ActiveConnection = MM_conn_STRING
==>
Set Recordset1.ActiveConnection = 这里是连接对象,不是字符串

[/Quote]应该怎么修改??
回复
cpp2017 2009-07-29
Recordset1.ActiveConnection = MM_conn_STRING
==>
Set Recordset1.ActiveConnection = 这里是连接对象,不是字符串
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告