程序运行自动把sql数据库中的记录总数显示出来出错!
Dim ProNum As Integer
rstoal.Open "select * from 表1", Conn, adOpenKeyset, adLockOptimistic
     If rstoal.RecordCount <> 0 Then
              ProNum = rstoal.RecordCount
              Label2.Caption = ProNum
              rs.Close    End If
数据库中有记录,但显示的怎么是-1

解决方案 »

  1.   

    在前面添加
    Conn.CursorLocation=adUseClient
      

  2.   

    有这么麻烦吗?直接
    con.excute("select count(*) from table1).fields(0).value
    就是记录的数
    其中con是数据库的连接对象
      

  3.   

    Dim ProNum As Integer
    rstoal.Open "select * from 表1", Conn, adOpenKeyset, adLockOptimistic
         If rstoal.RecordCount > 0 Then
                  ProNum = rstoal.RecordCount
                  Label2.Caption = str(ProNum)
                  rs.Close    End If
    可能是没有连接上数据库