我用一个简单SQL语句查询出一个结果集合,怎么样才能看到其中记录的个数呢?

解决方案 »

  1.   

    我试过了,但是调试时报错说: variable not defined ,recordset 被高亮显示
      

  2.   

    在工程中引用“Microsoft Actives Database Object 2.6 library”
    Private Sub Command1_Click()
    Dim cnn As ADODB.Connection
    Dim res As ADODB.Recordset
    Set cnn = New ADODB.Connection
    cnn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=chat1.MDB;jet oledb:database password=haha"
    Set res = New ADODB.Recordset
    res.Open "select * from name", cnn, 1, 3
    Text1.Text = res.RecordCount
    Set res = Nothing
    Set cnn = Nothing
    End Sub
    以上代码经过调试。
    你再试一试!!!
      

  3.   

    Dim cnn As New ADODB.Connection
    Dim res As New ADODB.Recordset
     cnn.open "连接串"
     res.Open "表名",cnn,..,..,adcmdtable
     Megbox  res.recordcount
      res.close
      

  4.   


    '在工程中引用“Microsoft Actives Database Object 2.6 library”
    Private Sub Command1_Click()
        Dim cn As ADODB.Connection
        Dim rs As ADODB.Recordset
        Set cnn = New ADODB.Connection
        cn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test.MDB"
        Set rs = New ADODB.Recordset
        rs.CursorLocation = adUseClient '必须加上这句
        rs.Open "select * from name", cnn, 1, 3
        Debug.Print rs.RecordCount
        rs.Close
        cn.Close
        Set rs = Nothing
        Set cn = Nothing
    End Sub
      

  5.   

    回复人: iamsoweak(Troy) ( ) 信誉:100  2003-12-14 21:23:00  得分:0 
     
     
      我试过了,但是调试时报错说: variable not defined ,recordset 被高亮显示
      
     ------------------------------------------recordset 是你所用的记录集合,你别直接用它啊