mshflexgrid 查询记录慢
我通过MSHFlexgrid 通过条件查记录,记录大概有一万4000条,速度需要1分半,太慢,并且第二次查询时,记录只与最后一行,前面都空白
代码如下:
Private Sub title1()
Dim L As Integer
m = Array(700, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500)
n = Array("序号", "工程号", "图档号", "板号", "条码", "尺寸", "颜色", "备注栏", "制程", "工作站")
For L = 0 To 9
MS1.ColWidth(L) = m(L): MS1.TextMatrix(0, L) = n(L)
Next L
End Sub
Private Sub Command1_Click()
MS1.Clear
Call title1
Adodc1.ConnectionString = PublicStr
Adodc1.RecordSource = "select * from scandata where 1=1"
If Text1.Text <> "" Then
Adodc1.RecordSource = Adodc1.RecordSource + " and gch='" + Text1.Text + "'"
End If
If Text2.Text <> "" Then
Adodc1.RecordSource = Adodc1.RecordSource + " and tdh='" + Text2.Text + "'"
End If
Adodc1.Refresh
Text3.Text = Adodc1.Recordset.RecordCount
If Adodc1.Recordset.RecordCount > 0 Then
Do While Adodc1.Recordset.EOF = False
MS1.Rows = Adodc1.Recordset.RecordCount + 1
On Error Resume Next
MS1.TextMatrix(MS1.Row, 1) = Adodc1.Recordset.Fields("gch")
MS1.TextMatrix(MS1.Row, 2) = Adodc1.Recordset.Fields("tdh")
MS1.TextMatrix(MS1.Row, 3) = Adodc1.Recordset.Fields("bh")
MS1.TextMatrix(MS1.Row, 4) = Adodc1.Recordset.Fields("barcode")
MS1.TextMatrix(MS1.Row, 5) = Adodc1.Recordset.Fields("cc")
MS1.TextMatrix(MS1.Row, 6) = Adodc1.Recordset.Fields("ys")
MS1.TextMatrix(MS1.Row, 7) = Adodc1.Recordset.Fields("bzl")
MS1.TextMatrix(MS1.Row, 8) = Adodc1.Recordset.Fields("zc")
MS1.TextMatrix(MS1.Row, 9) = Adodc1.Recordset.Fields("stationName")
Adodc1.Recordset.MoveNext
j = j + 1
MS1.AddItem (j)
MS1.Row = MS1.Row + 1
Loop
End If
For i = 1 To MS1.Rows
MS1.TextMatrix(i, 0) = i
Next i
End Sub
Private Sub Form_Load()
Call title1
End Sub
MSHFLEXGRID
[解决办法]
把 MSHFlexGrid 与 Adodc1 直接绑定,不要逐记录写入。每次查询后,刷新 MSHFlexGrid。
[解决办法]
If Adodc1.Recordset.RecordCount > 0 Then
set ms1.datasource=adodc1.recordset
end if