If AdoRs.State = adStateOpen Then AdoRs.Close End If ...... If AdoRs.RecordCount > 0 Then i = 0 With MSHFlexGrid1 .Rows = AdoRs.RecordCount + 1 .Cols = AdoRs.Fields.Count + 1
While Not AdoRs.EOF i = i + 1 .Row = i .Col = 0 .Text = i For j = 1 To AdoRs.Fields.Count .Col = j If IsNull(Trim(AdoRs.Fields(j - 1))) = True Or Trim(AdoRs.Fields(j - 1)) = 0 Then .Text = "" Else .Text = Trim(AdoRs.Fields(j - 1)) End If Next j AdoRs.MoveNext Wend End With MSHFlexGrid1.Redraw = True End If这样绑定的
将这两句挪一下位置试试 .Rows = AdoRs.RecordCount + 1 .Cols = AdoRs.Fields.Count + 1 挪到 If AdoRs.RecordCount > 0 Then 之前
AdoRs.Close
End If
......
If AdoRs.RecordCount > 0 Then
i = 0
With MSHFlexGrid1
.Rows = AdoRs.RecordCount + 1
.Cols = AdoRs.Fields.Count + 1
While Not AdoRs.EOF
i = i + 1
.Row = i
.Col = 0
.Text = i
For j = 1 To AdoRs.Fields.Count
.Col = j
If IsNull(Trim(AdoRs.Fields(j - 1))) = True Or Trim(AdoRs.Fields(j - 1)) = 0 Then
.Text = ""
Else
.Text = Trim(AdoRs.Fields(j - 1))
End If
Next j
AdoRs.MoveNext
Wend
End With
MSHFlexGrid1.Redraw = True
End If这样绑定的
.Rows = AdoRs.RecordCount + 1
.Cols = AdoRs.Fields.Count + 1
挪到
If AdoRs.RecordCount > 0 Then
之前