set datagrid.datasource=rsrs为分页过后的Recordset

解决方案 »

  1.   

    我不会rs分页,
    我只是定义了这些数据就不知道该怎么办了
    rs.pagesize=100
      

  2.   

    试试:
    Public Function a(currentpage As Integer) As String
    On Error GoTo errrow
        dim adocon as new adodb.connection
        Dim rs As New ADODB.Recordset
        Dim sConnect As String
        sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\VB98\NWIND.MDB;Mode=ReadWrite;Persist Security Info=False"
         adocon.Open sConnect
         a = ""
         Dim sql As String
         sql = "select * from table"
         rs.CursorLocation = adUseClient
         rs.PageSize = 7
            rs.CacheSize = rs.PageSize
            rs.open sql, adocon, adOpenKeyset, adLockOptimistic
            Dim ipagecount As Integer
            If Not (rs.EOF And rs.BOF) Then
             ipagecount = rs.PageCount
            End If
            If ipagecount <> 0 Then
             rs.AbsolutePage = currentpage
            End If
            Dim i As Integer
            i = 0
            While (Not rs.EOF) And (i <= rs.PageSize)
              a = a & rs(0) & "|#|"
              a = a & rs(1) & "|#|"
              i = i + 1
              rs.MoveNext
            Wend
            rs.close
            adocon.close
           Exit Function
    errrow:
           rs.close
           adocon.close
    End Function