当前位置: 代码迷 >> ASP >> 查询到两条记录,为什么rs.recordcount的值为-1?该怎么处理
  详细解决方案

查询到两条记录,为什么rs.recordcount的值为-1?该怎么处理

热度:112   发布时间:2012-02-24 16:30:38.0
查询到两条记录,为什么rs.recordcount的值为-1?
语句如下:
Set   rs=conn.execute( "select   *   from   studentinfo   where   idcard= ' "&idcard& " ' ")
if   rs.eof   and   rs.bof   then
      errormsg= "3 "
      response.Redirect   "client_stuinfofind.asp?errormsg= "&errormsg
      Set   rs=nothing
end   if
total=rs.recordcount
执行后查询到两条记录,想看看总共多少条记录,使用rs.recordcount,但是rs.recordcount的为-1

------解决方案--------------------
conn.execute 是没有游标的,要用adOpenKeyset游标
set rs = server.createobject( "adodb.recordset ")
rs.open "select *** ", conn, adOpenKeyset, adLockReadOnly

------解决方案--------------------
rs.open "select *** ", conn1,3