数据量大时,报错内容是:无法给MSFlexGrid分配内存.
请教各位大虾小虾,如何使MSFlexGrid分页显示,或如何解决这种问题?
假设共有2000条记录,MSFlexGrid1在接收1000条后将报错:无法给MSFlexGtid分配内存 怎样可以显示2000条记录?
下面是代码,帮忙修改下
Private Sub Form_Load()
Dim rs As ADODB.Recordset
Dim Sql As String
Dim i As Integer
ConnectionDatabase
Set rs = New ADODB.Recordset
Sql = "select * from user_table"
rs.Open Sql, conn, adOpenStatic
With MSFlexGrid1
.ColWidth(0) = 0
.Cols = rs.Fields.Count + 1
.Rows = rs.RecordCount + 1
.Row = 0
.Col = 0
For i = 1 To .Cols - 1
.Col = i
.Text = rs(i - 1).Name
Next
Do While Not rs.EOF
If .Row <= .Rows - 1 Then
.Row = .Row + 1
.Col = 0
For i = 1 To .Cols - 1
.Col = i
.Text = Trim(rs(i - 1).Value) & ""
Next
End If
rs.MoveNext
Loop
End With
End Sub