recordset的问题,我都快烦死了

big_welley 2002-05-11 10:02:52
请大家帮我看一下,问题出在哪
Set MyConn=Server.CreateObject("ADODB.Connection")
Set Rs=Server.CreateObject("ADODB.RecordSet")
Rs.ActiveConnection=MyConn
MyConn.Open Session("connect")
Rs.Execute "Select * from table"
MyConn.Close

<%IF Rs.RecordCount=0 THEN%> (老提示这里出错)
.....
<%
END IF
%>
...全文
60 17 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
possible_Y 2002-05-12
  • 打赏
  • 举报
回复
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open Session("connect")
Set Rs=Server.CreateObject("ADODB.RecordSet")
Rs.ActiveConnection=MyConn
Rs.CursorType = 3
Rs.LockType = 3
Rs.Execute "Select * from table"
MyConn.Close

<%IF Rs.RecordCount=0 THEN%> (老提示这里出错)
.....
<%
END IF
%>
netying 2002-05-12
  • 打赏
  • 举报
回复
http://www.csdn.net/expert/topic/692/692125.xml?temp=.7810633
BrightEye 2002-05-12
  • 打赏
  • 举报
回复
用1,1方式打开肯定可以.
还有你的活动连接已经关闭了,还用游标rs.recordcount,这个也会发生错误的.
jamwaychen 2002-05-12
  • 打赏
  • 举报
回复
受教,受教
wuya0531 2002-05-12
  • 打赏
  • 举报
回复
我说怎么回事呢,recordcount总是-1,原来还是有说法的,呵呵
chinatorpedo 2002-05-12
  • 打赏
  • 举报
回复
前面 saucer(思归)答的也很好跟我的想法一样
chinatorpedo 2002-05-12
  • 打赏
  • 举报
回复
MyConn.Close联接关的太早了吧
资源被释放了还能用把它放到最后一行试一试
wang0628 2002-05-12
  • 打赏
  • 举报
回复
同意saucer(思归)和tripofdream(梦之旅)
tripofdream 2002-05-11
  • 打赏
  • 举报
回复
使用execute方法打开的记录集其Recordcount值都是-1,要得到正确的Recordcount,需要要open方法打开记录集.
sunbeamy 2002-05-11
  • 打赏
  • 举报
回复
楼上的,你也看看下面的帖子吧~~~
http://www.csdn.net/expert/topic/692/692125.xml?temp=.7810633
jamwaychen 2002-05-11
  • 打赏
  • 举报
回复
最好不要用recordcount,好象有时候返回错误的数,有时候明明有记录却会返回负数(我试过)。
试一试
if rs.eof or rs.bof then
我用过一次,可以用
sunbeamy 2002-05-11
  • 打赏
  • 举报
回复
wt423(游子),应该是
----------------------------------------------------
Set Rs=MyConn.execute "select * from table"
big_welley 2002-05-11
  • 打赏
  • 举报
回复
不好意思是我写错了
是Rs=MyConn.execute "select * from table"
执行的时候指示的是Rs.Recordcount=0这行有错
sunbeamy 2002-05-11
  • 打赏
  • 举报
回复
http://www.csdn.net/expert/topic/692/692125.xml?temp=.7810633
wt423 2002-05-11
  • 打赏
  • 举报
回复
Rs.Execute "Select * from table"
有错!
Rs是记录集对象。没有Execute方法
可以这样
Rs=MyConn.execute "select * from table"
或者
Rs.open "select * from table",MyConn,1,3
popcode 2002-05-11
  • 打赏
  • 举报
回复
错误类型
saucer 2002-05-11
  • 打赏
  • 举报
回复
Set MyConn=Server.CreateObject("ADODB.Connection")
Set Rs=Server.CreateObject("ADODB.RecordSet")
MyConn.Open Session("connect")
Rs.Open "Select * from YourtableName",MyConn,3,1

IF Rs.RecordCount=0 then '或 if Rs.EOF THEN

end if

Rs.Close
MyConn.Close


28,409

社区成员

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

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