搞了几天拉!还是没有解决啊!在线等待!!!!

nokir 2003-12-01 12:30:13
我和数据库的连接和打开已经成功了,但是我现在要的在数据库里查询数据,但是怎么搞也没有成功啊!我在查询时它给我的提示是:
错误类型:
ADODB.Recordset (0x800A0CC1)
在对应所需名称或序数的集合中,未找到项目。
/make/在Access数据库中查询数据.asp, 第 35 行


浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

网页:
POST 18 ??? /make/在Access数据库中查询数据.asp

POST Data:
product_code=01123

我的代码是这样的,请大家帮我分析一下啊!
<%
'声明Recordset对象
Set RS=Server.CreateObject("ADODB.Recordset")
'打开数据库中的数据表 ,并使用 静态记录指针 ,也可以使用索引记录指针
RS.open "product" , DBConnection ,1,2
if Request("product_code") <> empty then
' 设置查询的数据的数据
Condition ="标号=' " & request("product_code") & " ' "
' 将寻找的条件指定给RS.Find
RS.Find =Condition ////////第 35 行
if RS.eof then
response.Write " 很抱歉!查无此标号为 "& request("product_code") & "的产品 "
else
response.Write " 查询到的产品如下:<br> <font size=2 color=blue> "
for i=0 to RS.FIelds.Count-1
response.Write RS(i) & "<br>"
next
response.Write " </font>"
end if
end if
%>
...全文
60 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
blueice2002 2003-12-01
  • 打赏
  • 举报
回复
asp与sql server 数据库的连接
<%
'连接数据库————————————————————————————
set conn=server.createobject("adodb.connection")
Connstr="Provider=SQLOLEDB;Data Source=127.0.0.1;UID=sa;PWD=sa;DataBase=web"
'打开数据库——————————————————————————————————
conn.open connstr
'写数据查询语句————————————————————————
set rs=conn.execute("select * from asp where id>2")
'输出查询结果——————————————————————————
do until rs.eof
response.write rs("id")&"<br>"
response.write rs("name")&"<br>"
rs.movenext
loop
%>
************************************
asp与access 数据库的连接
********************************
<% dim conn
dim connstr
on error resume next
connstr="DBQ="+server.mappath("login.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
if err then
err.clear
else
conn.open connstr
if err then
err.clear
end if
end if
set rs=conn.execute("select * from login_info where id>1")
do until rs.eof
response.write rs("id")&"<br>"
response.write rs("username")&"<br>"
response.write rs("password")&"<br>"
rs.Movenext
loop %>

*****************************************************
*****************************************************
<!--#include file="conn.asp"-->
<%
set rs=conn.execute("select * from login_info where id>2")
'set rs=server.createobject("adodb.recordset")
'sql="select * from login_info where id > ='1' "
'rs.open sql,conn,1,1
do until rs.eof
response.write rs("id")&"<br>"
response.write rs("username")&"<br>"
response.write rs("password")&"<br>"
rs.Movenext
loop
%>

**********************************************************
***********************************************************

连结其他数据库的方法(*.dbf,*.txt,excel,foxpro等) ----收藏
2002-10-30 18:41:05 浏览次数:145

'连结dbf文件
<%
' 建立Connection 对象
Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Visual FoxPro Driver};"
SourceType = "SourceType=DBF;"
DBPath = "SourceDB=" & Server.MapPath( "Dbf" )

' 调用Open 方法连接数据库
conn.Open Driver & SourceType & DBPath

Set rs = Server.CreateObject("ADODB.Recordset")
' 打开数据源,参数二为Connection对象
rs.Open "Select * From sample", conn, 2, 2
%>
'连结foxpro文件
<%
' 建立Connection 对象
Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Visual FoxPro Driver};"
SourceType = "SourceType=DBC;"
DBPath = "SourceDB=" & Server.MapPath( "Dbf/Sample.dbc" )

' 调用Open 方法连接数据库
conn.Open Driver & SourceType & DBPath

Set rs = Server.CreateObject("ADODB.Recordset")
' 打开数据源,参数二为Connection对象
rs.Open "Select * From sample", conn, 2, 2
%>

'连结excel文件
<%
' 建立Connection对象
Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Excel Driver (*.xls)};"
DBPath = "DBQ=" & Server.MapPath( "Sample.xls" )

' 调用Open 方法连接数据库
conn.Open Driver & DBPath

Set rs = Server.CreateObject("ADODB.Recordset")
' 打开数据源,参数二为Connection对象
rs.Open "Select * From [成绩单$]", conn, 2, 2
%>

'连结txt文件
<%
' 建立Connection 对象
Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Text Driver (*.txt; *.csv)};"
DBPath = "DBQ=" & Server.MapPath( "Text" )

' 调用Open 方法连接数据库
conn.Open Driver & DBPath

Set rs = Server.CreateObject("ADODB.Recordset")
' 打开数据源,参数二为Connection对象
rs.Open "Select * From sample.txt", conn, 2, 2
%>






SELECT语法:(基本)



*************************************************************
**********************************************************
SELECT [DISTINCT]
(column [{, column } ] )| *
FROM table [ { , table} ]
[ORDER BY column [ASC] | [DESC
[{ , column [ASC] | [DESC } ] ]
WHERE predicate [ { logical-connector predicate } ];
------------------------------------------------------

INSERT语法:

INSERT INTO table
[(column { ,column})]
VALUES
(columnvalue [{,columnvalue}]);
------------------------------------------------------

UPDATE语法:

UPDATE table
SET column = value [{, column = value}]
[ WHERE predicate [ { logical-connector predicate}]];
------------------------------------------------------

DELETE语法:

DELETE FROM table
[WHERE predicate [ { logical-connector predicate} ] ];
------------------------------------------------------
blueice2002 2003-03整理----hshlin.8u8.com qq:14605617
msn:blueicceblue@hotmail.com
wsmall 2003-12-01
  • 打赏
  • 举报
回复
你的product是什么?
sql语句么/
如果是的。
请检查,可能你的sql语句,有问题,拿出来看看
suhuoqiang 2003-12-01
  • 打赏
  • 举报
回复
在对应所需名称或序数的集合中,未找到项目。

不对应吧
nokir 2003-12-01
  • 打赏
  • 举报
回复
我使用的是Access数据库
nokir 2003-12-01
  • 打赏
  • 举报
回复
谢谢各位啊!·
  • 打赏
  • 举报
回复
find方法好象是vb中的用法,asp中有该方法吗?我不太肯定。
另外RS.open "product" , DBConnection ,1,2 写法不对。

把这下面的改掉:
RS.open "product" , DBConnection ,1,2 ////// product为access数据库中的表
if Request("product_code") <> empty then
' 设置查询的数据的数据
Condition ="标号=' " & request("product_code") & " ' "
' 将寻找的条件指定给RS.Find
RS.Find =Condition ////////第35行

改为
sql="select * from table "
if Request("product_code") <> empty then
Condition ="标号=' " & request("product_code") & " ' "
sql=sql&condition
end if

set rs=dbconnection.execute(sql)
nokir 2003-12-01
  • 打赏
  • 举报
回复
我是ASP的初学者,对有些东西不是很懂啊!我是按照一些资料写的程序,整个代码是这样的!:请大家看看问题出在那里啊!
//////////////////////////////////
<% @LANGUAGE=VBScript %>
<html>
<title>使用ADO向Access数据表中查询数据</title>
<body bgcolor=#ff00ff>
<center>
首先使用ADO连接Access数据库 ,直接写代码。<br>
<hr>
<% ' 声明Connection(数据库连接)对象
Set DBConnection=Server.CreateObject("ADODB.Connection")
'设置与数据库连接的连接字符串
ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " & Server.MapPath("book.mdb")
'打开数据库
DBConnection.Open ConnectionString
%>
<h2>恭喜你!使用ADO连接Access数据库 成功!</h2>
<hr>
再使用ADO在Access数据库中查询数据 。<br>
<form name="FormGet1" method="post" action="在Access数据库中查询数据.asp">
请在此输入产品的标号:
<input type="text" name="product_code" size="10"><br>
<input type="submit" value="确定" > <br>
</form>
</center>
</body>
</html>
<%
'声明Recordset对象
Set RS=Server.CreateObject("ADODB.Recordset")
'打开数据库中的数据表 ,并使用 静态记录指针 ,也可以使用索引记录指针
RS.open "product" , DBConnection ,1,2 ////// product为access数据库中的表
if Request("product_code") <> empty then
' 设置查询的数据的数据
Condition ="标号=' " & request("product_code") & " ' "
' 将寻找的条件指定给RS.Find
RS.Find =Condition ////////第35行
if RS.eof then
response.Write " 很抱歉!查无此标号为 "& request("product_code") & "的产品 "
else
response.Write " 查询到的产品如下:<br> <font size=2 color=blue> "
for i=0 to RS.FIelds.Count-1
response.Write RS(i) & "<br>"
next
response.Write " </font>"
end if
end if
%>
//////这就是整个的代码!我和数据库的连接,打开都是这样写的!暂时还没有写什么SQL语句啊!请高手仔细的给我讲讲咯!

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧