Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordsetcmd = "provider=microsoft.jet.oledb.4.0;" & "data source=" & "c:\fan choice\fan.mdb" Dim strsql As String
 strsql = "select * from fan"
 
 rs.Open strsql, cmd, adOpenDynamic
打开成功后,该如何得到记录数。
为何
  i = rs.RecordCount
   i==-1;

解决方案 »

  1.   

    Rs.CursorLocation = adUseClient    Rs.Open "select * from employees", CN, adOpenDynamic, adLockOptimistic
       msgbox Rs.RecordCount
      

  2.   

    rs.Open strsql, cmd, adOpenDynamicif rs.BOF and rs.EOF then
       i=0   '没有记录
    else
       rs.movefirst
       rs.movelast
       i=rs.recordcount
    end if
      

  3.   

    Rs.CursorLocation = adUseClient为客户端游标就可以了
      

  4.   

    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordsetcmd = "provider=microsoft.jet.oledb.4.0;" & "data source=" & "c:\fan choice\fan.mdb"Dim strsql As String
    strsql = "select * from fan"
    '*添加下面这句就行了
    rs.CursorLocation = adUseClient  '*客户端游标
    rs.Open strsql, cmd, adOpenDynamic