rs.recordcount怎么为-1呢?

pzzyj 2005-02-20 11:59:50
我连接的是sql server数据库
选了一张表,表中是有数据的

...
dim rs
set rs=server.createobject("adodb.recordset")
rs.open "[表]",conn,1,1
....


response.write rs.recordcount
response.write rs.absolutepage

输出的结果为都为-1,这是什么原因?
...全文
174 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
pzzyj 2005-02-26
  • 打赏
  • 举报
回复
问题已经解决
yctcsms 2005-02-20
  • 打赏
  • 举报
回复
游标类型怎么改?
newsuperstar 2005-02-20
  • 打赏
  • 举报
回复
改一下游标类型
surfchen 2005-02-20
  • 打赏
  • 举报
回复
用rs.fields.count不行吗?
trtrsoft 2005-02-20
  • 打赏
  • 举报
回复
rs.recordcount 只有在记录指针滚到记录尾以后 才会有正确的值
wsdzmhongm 2005-02-20
  • 打赏
  • 举报
回复
...
dim rs
set rs=server.createobject("adodb.recordset")
rs.CursorLocation=3
rs.open "[表]",conn,1,1
....
jnzsk 2005-02-20
  • 打赏
  • 举报
回复
我也遇到过这样的问题!请高手解决
pjl20005 2005-02-20
  • 打赏
  • 举报
回复
数据库连接正确吗?表单名没错吧
raline 2005-02-20
  • 打赏
  • 举报
回复
rs.open "[表]",conn,1,1
我第一次这样打开数据库哦,实在不懂
我一般 rs.open sql,conn,1,1
sql="select * from pyourtable"
不要定义SQL,直接OPEN也应该按格式吧
rs.open "select * from pyourtable",conn,1,1
还请大家指教
swordsman2000 2005-02-20
  • 打赏
  • 举报
回复
rs.open "[表]",conn,3,1
valu 2005-02-20
  • 打赏
  • 举报
回复
...
Dim rs
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.open "select * from pyourtable]", conn, 1
....
newsuperstar 2005-02-20
  • 打赏
  • 举报
回复
用下面的试一下:
rs.open "Enterpriess",conn,3,1
pzzyj 2005-02-20
  • 打赏
  • 举报
回复
<!--#include file="conn/conn.asp" -->
<%
'Enterpriess表里有三百多条记录
set rs=server.CreateObject("adodb.recordset")
rs.open "Enterpriess",conn,1,3
response.write rs.recordcount
%>

输入的结果是-1 这是原因?????
是是非非 2005-02-20
  • 打赏
  • 举报
回复
rst.CursorLocation=adUseClient
wungshly 2005-02-20
  • 打赏
  • 举报
回复
表里面没有内容
返回值为-1
suhongwei 2005-02-20
  • 打赏
  • 举报
回复
设了pagesize了吗
演示: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 %>
操作简单,适合小型手机店铺。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

28,391

社区成员

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

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