VB 实时错误 SELECT 子句中包含一个保留字、拼写错误或丢失的参数,或标点符号不正确。 5
SubFillMSHFlexGrid1()Setrs=NewADODB.Recordsetrs.ActiveConnection=cnrs.OpenstrSql,cn,a...
Sub FillMSHFlexGrid1()
Set rs = New ADODB.Recordset
rs.ActiveConnection = cn
rs.Open strSql, cn, adOpenKeyset, adLockPessimistic
If rs.RecordCount > 0 Then rs.MoveFirst
With MSHFlexGrid1
.Clear
.ColWidth(0) = 900: .ColWidth(1) = 1200: .ColWidth(2) = 500
.ColWidth(3) = 1100: .ColWidth(4) = 1900: .ColWidth(5) = 700
If rs.RecordCount > 0 Then .Rows = rs.RecordCount + 1 Else .Rows = 2
.RowHeight(0) = 350
Dim fld As ADODB.Field
Set flds = rs.Fields
.Cols = flds.Count
i = 0
For Each fld In flds
.TextMatrix(0, i) = fld.Name
.ColAlignmentFixed(i) = flexAlignCenterCenter
.ColAlignment(i) = flexAlignLeftCenter
i = i + 1
Next
i = 0
Do Until rs.EOF
i = i + 1: j = 0
For Each fld In flds
If Not IsNull(fld.Value) Then .TextMatrix(i, j) = Trim(fld.Value): j = j + 1
Next
rs.MoveNext
Loop
End With
End Sub
按调试就如下 展开
Set rs = New ADODB.Recordset
rs.ActiveConnection = cn
rs.Open strSql, cn, adOpenKeyset, adLockPessimistic
If rs.RecordCount > 0 Then rs.MoveFirst
With MSHFlexGrid1
.Clear
.ColWidth(0) = 900: .ColWidth(1) = 1200: .ColWidth(2) = 500
.ColWidth(3) = 1100: .ColWidth(4) = 1900: .ColWidth(5) = 700
If rs.RecordCount > 0 Then .Rows = rs.RecordCount + 1 Else .Rows = 2
.RowHeight(0) = 350
Dim fld As ADODB.Field
Set flds = rs.Fields
.Cols = flds.Count
i = 0
For Each fld In flds
.TextMatrix(0, i) = fld.Name
.ColAlignmentFixed(i) = flexAlignCenterCenter
.ColAlignment(i) = flexAlignLeftCenter
i = i + 1
Next
i = 0
Do Until rs.EOF
i = i + 1: j = 0
For Each fld In flds
If Not IsNull(fld.Value) Then .TextMatrix(i, j) = Trim(fld.Value): j = j + 1
Next
rs.MoveNext
Loop
End With
End Sub
按调试就如下 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询