读取wincc归档数据的时候不能在listview中显示新归档的数据

已锁定

yixuan

  • 帖子

    8
  • 精华

    0
  • 被关注

    0

论坛等级:游民

注册时间:2010-12-22

普通 普通 如何晋级?

读取wincc归档数据的时候不能在listview中显示新归档的数据

875

0

2012-05-11 10:32:36

大侠们,为什么我在读取wincc归档数据的时候不能在listview中显示新归档的数据啊,只是显示老的数据,我采用的是相对时间查询的,数据库里面的数据肯定更新了,从其他程序里面可以看到
代码如下:
Dim sPro, sDsn, sSer,sCon, sSql
Dim sVid, sVal, lRet, sRel
Dim V,Sum,Avg,Std
Dim conn, oRs, oCom, oList, oItem
Dim m,n,s,nRec
Dim strDateTime, iMs ,jMs

' 0.0 Get parameters from picture
sDsn = ScreenItems("laDSN").Text
sSer = ScreenItems("laServer").Text
sSql = ScreenItems("laSql").Text
' 1.1 Make connection string for ADODB as indicated below
'"Provider=WinCCOLEDBProvider.1;Catalog=CC_V6_Demo3_03_02_04_16_19_15R;Data Source=.\WinCC"
' 1.2 Define command text in sSql for WinCC compressed archives, relative time
sPro = "Provider=WinCCOLEDBProvider.1;"
sDsn = "Catalog=" + sDsn + ";"
sSer = "Data Source=" + sSer + "\WinCC"
sCon = sPro + sDsn + sSer
nRec = NMAX
' "TAG:R,1,'0000-00-00 00:05:00.000','0000-00-00 00:00:00.000'"
lRet = MsgBox("Opened with " & vbCr & sCon & vbCr & sSql & vbCr, vbOKCancel)
If lRet <> 1 Then Exit Sub
' 2.1 Make connection
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = sCon
conn.CursorLocation = adUseClient ' 3
conn.Open
' 2.2 Use command text for query
Set oRs = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command")
oCom.CommandType = 1 ' adCmdText = 1
Set oCom.ActiveConnection = conn
oCom.CommandText = sSql

'2.3 Fill the recordset
Set oRs = oCom.Execute
m = oRs.Fields.Count

' 3.0 Fill standard listview object with recordset
Set oList = ScreenItems("ListTable")
oList.ListItems.Clear
If(m>0) Then
oRs.MoveFirst
If( n < nRec ) Then
SplitDateTimeAndMs oRS.Fields(1).Value, strDateTime, iMs
s = FormatDateTime(strDateTime,2) & " " & FormatDateTime(strDateTime,3)
Set oItem = oList.ListItems.Add()
oItem.Text = s + "."+iMs
Select Case FormatNumber(V, 4)
Case 10.0000
oItem.SubItems(1) = "门禁故障解除"

Case Else
oItem.SubItems(1) = "错误信息"
End Select

End If
oRs.MoveNext
Loop
oRs.close

End If

Set oRs = Nothing
conn.Close
Set conn = Nothing
Set oCom = Nothing
读取wincc归档数据的时候不能在listview中显示新归档的数据 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-300/400

共有54618条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。