现在我已经利用OLEDB读出了归档数据,但怎么样把结果集显示在画面里呢,用的什么控件呢?看到示例中大都用到listview控件,它的全名是什么啊。我的系统里只有一个叫Microsoft listview control 6.0 (sp6),添加到画面里是一个白板,是这个吗?
给个WINCC控制listview的实例好吗?我用了好几个代码,没有反应,困扰了老长时间了。您看我的代码有什么问题吗?它只能显示出一个时间来,就没有反应了。
Sub OnLButtonDown(ByVal Item, ByVal Flags, ByVal x, ByVal y)
Dim sPro
Dim sDsn
Dim sSer
Dim sCon
Dim sSql
Dim oRs
Dim conn
Dim oCom
Dim oItem
Dim m, n, s,i
Dim oList
sPro = "Provider=WinCCOLEDBProvider.1;"
sDsn = "Catalog=CC_tanks_09_07_14_10_38_56R;"
sSer = "Data Source=.\WinCC"
sCon = sPro + sDsn + sSer
sSql = "TAG:R,'tanks\aa','2009-07-16 00:00:00','2009-07-17 00:00:00'"
MsgBox "Open with:" & vbCr & sCon & vbCr & sSql & vbCr
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = sCon
conn.CursorLocation = 3
conn.Open
Set oRs = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command")
oCom.CommandType = 1
Set oCom.ActiveConnection = conn
oCom.CommandText = sSql
Set oRs = oCom.Execute
n=oRs.RecordCount
MsgBox(n)
Set oList = ScreenItems("控件1")
oList.ListItems.Clear
If(n>0) Then
oRs.MoveFirst
MsgBox(">0")
End If
m = 0
Do While Not oRs.EOF
m = m + 1
Set oItem = oList.ListItems.Add()
oItem.Text = Left(CStr(oRs.Fields(1).Value), 23)
oItem.SubItems(1) = FormatNumber(oRs.Fields(2).Value, 4)
oItem.SubItems(2) = Hex(oRs.Fields(4).Value)
If m > 100 Then
Exit Do
Else
MsgBox(m)
End If
oRs.MoveNext
Loop
oRs.Close
Set oRs = Nothing
conn.Close
Set conn = Nothing
End Sub