为什么rs.recordcount=-1???

zgysc 2003-02-12 05:16:58
我的sql语句是
set conn=server.createobject("adodb.connection")
conn.open "数据库连接字符串"
set rs=server.createobject("adodb.recordset")
“select * from 表名”,con,1,3
执行该语句可以取得值,但为什么rs.recordcount=-1???
...全文
53 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
lonwin 2003-02-13
  • 打赏
  • 举报
回复
在你的程序中加上
<!--METADATA NAME="Microsoft ActiveX Data Objects 2.5 Library"
TYPE="TypeLib" UUID="{00000205-0000-0010-8000-00AA006D2EA4}"-->

rs.cursortype=aduseclient


试试吧没问题的!:)
standy 2003-02-13
  • 打赏
  • 举报
回复
我采用的也是ORACLE DB,也碰到过类似问题,有时候同样的程序对于不同的DB有的运行正常,有的运行出现这种情况
实际上这是DB的配置问题,RECORDCOUNT这种属性需要遍历一次查询结果,数据量很大的时候对数据库是一个不小的负荷,所以DBA大概把这个属性达到一定的记录数就关闭了此属性
fbj007 2003-02-13
  • 打赏
  • 举报
回复
游标类型设置的不对
shanhe 2003-02-13
  • 打赏
  • 举报
回复
我的感觉是不同数据库对于游标机制的实现不一样,所以导致不能够正确处理纪录条数的统计。
lonwin 2003-02-13
  • 打赏
  • 举报
回复
好像不是参数的事吧,1,3应该没问题的,
linday 2003-02-13
  • 打赏
  • 举报
回复
“select * from 表名”,con,1,1
flyinweb 2003-02-13
  • 打赏
  • 举报
回复
改变open语句后面的参数吧
zgysc 2003-02-13
  • 打赏
  • 举报
回复
我忘了告诉大家,我连接的是oracle,同样是刚才的语句,连接sqlsever就没有问题,
par 2003-02-12
  • 打赏
  • 举报
回复
“select * from 表名”,con,记录集游标,锁定类型


记录集游标:
1:前向
2:向前向后
3:动态
4:静态

锁定类型:
1:不能修改记录
2:编辑时锁定
3:调用UPDATE时锁定
4:成批更新
Javaxhb 2003-02-12
  • 打赏
  • 举报
回复
rs.CursorLocation = adUseClient
zxhong 2003-02-12
  • 打赏
  • 举报
回复
con,1,3
-->
con,1,1
ShiningstarHu 2003-02-12
  • 打赏
  • 举报
回复
“select * from 表名”,con,1,3
该成
“select * from 表名”,con,3,1
试试
muddledman 2003-02-12
  • 打赏
  • 举报
回复
rs.open sql,conn,1
我以前也遇到过类似的问题,好像是sql语句的问题,虽然能在数据库中读取!不过多了一个()就导致rs.recordcount=-1这种结果了!仔细看看
par 2003-02-12
  • 打赏
  • 举报
回复
返回第一条记录
wsj 2003-02-12
  • 打赏
  • 举报
回复
rs.movelast
rs.movefirst
rs.recordcount
操作简单,适合小型手机店铺。Dim rs1 As New ADODB.Recordset Private Sub cmdexit_Click() frmmain.Visible = True Unload Me End Sub Private Sub cmdOK_Click() If txtuserid.Text = "" Then MsgBox "请输入操作员编号!", vbOKOnly + vbInformation, "修改密码" txtuserid.Text = "" txtuserid.SetFocus Exit Sub Else rs1.Open "select * from 密码 where 操作员编号= '" & Trim(txtuserid.Text) & "'", cnn, adOpenKeyset, adLockOptimistic If rs1.RecordCount > 0 Then txtusername.Text = Trim(rs1.Fields("操作员名称")) End If rs1.Close End If If txtusername.Text = "" Then MsgBox "操作员编号不存在!", vbOKOnly + vbInformation, "修改密码" txtuserid.Text = "" txtuserid.SetFocus Exit Sub End If If txtoldpass.Text = "" Then MsgBox "请输入旧密码!", vbOKOnly + vbInformation, "修改密码" txtoldpass.SetFocus Exit Sub End If If txtnewpass.Text = "" Then MsgBox "请输入新密码!", vbOKOnly + vbInformation, "修改密码" txtnewpass.SetFocus Exit Sub End If If txtnewpass1.Text = "" Then MsgBox "请再次输入新密码!", vbOKOnly + vbInformation, "修改密码" txtnewpass1.SetFocus Exit Sub End If rs1.Open "select * from 密码 where 操作员编号= '" & Trim(txtuserid.Text) & "'", cnn, adOpenKeyset, adLockOptimistic If rs1.RecordCount > 0 Then If txtoldpass.Text <> Trim(rs1.Fields("密码")) Then MsgBox "旧密码不正确!", vbOKOnly + vbInformation, "修改密码" txtoldpass.Text = "" txtoldpass.SetFocus Else If txtnewpass.Text = txtnewpass1.Text Then rs1.Fields("密码") = txtnewpass.Text rs1.Update MsgBox "密码修改成功!", vbOKOnly + vbInformation, "修改密码" rs1.Update txtuserid.SetFocus Else MsgBox "两次输入的密码不一致,请重新输入!", vbOKOnly + vbInformation, "修改密码" txtnewpass.Text = "" txtnewpass1.Text = "" txtnewpass.SetFocus End If End If End If rs1.Close End Sub Private Sub Form_Activate() txtuserid.SetFocus End Sub Private Sub txtNewPass_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtnewpass1.SetFocus End If End Sub Private Sub txtNewPass1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cmdok.SetFocus End If End Sub Private Sub txtOldPass_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtnewpass.SetFocus End If End Sub Private Sub txtUserId_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtoldpass.SetFocus End If End Sub Private Sub txtUserId_Change() txtusername.Text = "" txtoldpass.Text = "" txtnewpass.Text = "" txtnewpass1.Text = "" End Sub Private Sub txtuserid_LostFocus() rs1.Open "select * from 密码 where 操作员编号= '" & Trim(txtuserid.Text) & "'", cnn, adOpenKeyset, adLockOptimistic If rs1.RecordCount > 0 Then If rs1.RecordCount > 0 Then txtusername.Text = Trim(rs1.Fields("操作员名称")) If txtusername.Text = "" Then MsgBox "操作员编号不存在!", vbOKOnly + vbInformation, "修改密码" txtuserid.Text = "" txtuserid.SetFocus Exit Sub End If End If End If rs1.Close End Sub
演示:http://asp2004.net/temp/treemenu/ 下载地址:http://asp2004.net/temp/treemenu.rar 关键代码: <% set conn=server.createobject("ADODB.CONNECTION") connstr="DBQ="+server.mappath("db1.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};" conn.open connstr function menu(id) set rs=server.CreateObject("adodb.recordset") sql="select * from menu where id1="&id&" order by url,id" rs.open sql,conn,1,1 if rs.recordcount=0 then rs.close set rs=nothing exit function end if response.write("") i=1 while not rs.eof if len(rs("url"))>0 then if i=rs.recordcount then menutype="file1" else menutype="file" end if menuname=""&rs("menuname")&"" onmouseup="" else if i=rs.recordcount then menutype="menu3" listtype="list1" onmouseup="with(eval('id"&rs("id")&"'))if(style.display==''){style.display='none';this.className='menu3';}else{style.display='';this.className='menu4';}" else menutype="menu1" listtype="list" onmouseup="with(eval('id"&rs("id")&"'))if(style.display==''){style.display='none';this.className='menu1';}else{style.display='';this.className='menu2';}" end if menuname=rs("menuname") end if %> <%if len(rs("url"))<3 then%> " style="display:none"> <% end if rs.movenext i=i+1 wend response.write("
<%menu(rs("id"))%>
") rs.close set rs=nothing end function %> =========无限级目录树=========http://bbs.asp2004.net http://bbs.asp2004.net/提供最新下载《管理
<% menu 0 conn.close set conn=nothing %>

28,390

社区成员

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

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