用OLE-DB读取过程值归档中的变量,在LISTVIEW控件中显示,可显示的是变量存储的时间,不是变量的值,这是什么问题啊,请教各位高手啊,急!!!!!!!!,程序如下:
Dim sPro As String
Dim sDsn As String
Dim sSer As String
Dim sCon As String
Dim sSql As String
Dim conn As Object
Dim oRs As Object
Dim oCom As Object
Dim oItem As Object
Dim m, n, s
sPro = "Provider=winccoledbprovider.1;"
sDsn = "catalog=cc_celiang_05_11_27_08_39_50R;"
sSer = "data source=.\wincc"
sCon = sPro + sDsn + sSer
sSql = "TAG:R,'mydata\newtag','0000-00-00 00:10:00.000','0000-00-00 00:00:00.000'"
sSql = "TAG:R,1,'0000-00-00 00:10:00.000','0000-00-00 00:00:00.000'"
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
m = oRs.fields.Count
listview1.columnheaders.Clear
listview1.columnheaders.Add , , CStr(oRs.fields(1).Name), 140
listview1.columnheaders.Add , , CStr(oRs.fields(2).Name), 70
listview1.columnheaders.Add , , CStr(oRs.fields(3).Name), 70
If (m > 0) Then
oRs.movefirst
n = 0
Do While Not oRs.EOF
n = n + 1
s = Left(CStr(oRs.fields(1).value), 23)
Set oItem = listview1.listitrms.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(3).value)
If (n > 10000) Then Exit Do
oRs.movenext
Loop
oRs.Close
Else
End If
Set oRs = Nothing
conn.Close
Set conn = Nothing