'各位好!
'咨詢下使用Wincc MShflexgrid連接SQLserver數(shù)據(jù)庫時,想顯示數(shù)據(jù)庫中所有內(nèi)容,但是激活后只顯示一行數(shù)據(jù)是怎么回事,實際數(shù)據(jù)庫中有40條數(shù)據(jù)。
'以下部分前后有省略,代碼如下:
················································
ssql1= "SELECT * FROM [Data].[dbo].[Recipe]"
Set oCom.ActiveConnection = Conn
oCom.CommandText = ssql1
Set oRs1 = oCom.Execute
m = oRs1.RecordCount
'---------------------設置控件顯示--------------------'
Dim alllist
Set alllist = ScreenItems("報表")
alllist.clear
alllist.Cols=8
alllist.Rows = m+1
'---------------------將數(shù)據(jù)寫入表格--------------------'
oRs1.Movefirst
For i = 1 To m
alllist.TextMatrix(i,0) = i
alllist.TextMatrix(i ,1) = oRs1.fields(0).Value
alllist.TextMatrix(i ,2) = oRs1.Fields(1).Value
alllist.TextMatrix(i ,3) = oRs1.Fields(2).Value
alllist.TextMatrix(i ,4) = oRs1.Fields(3).Value
alllist.TextMatrix(i ,5) = oRs1.Fields(4).Value
alllist.TextMatrix(i ,6) = oRs1.Fields(5).Value
alllist.TextMatrix(i ,7) = oRs1.Fields(6).Value
alllist.TextMatrix(i ,8) = oRs1.Fields(7).Value
oRs1.movenext
Next
········································