查询归档信息一般用控件就可以搞定,但是有时需要显示数据就需要编辑一个脚本,下面是我编写的一个脚本,希望大家可以提出更好地!!!
Dim str1,str2,str3,str4,sPro,sDsn,sCon,sSer,sSql,conn,oRs,oCOm,sStartDay,sEndDay
str2 = ".\Wincc"
str1 = "CC_OS_2__14_08_01_14_03_33R" '改对应项目的归档
sPro = "Provider=WinCCOLEDBProvider.1;"
sDsn = "Catalog=" + str1 + ";"
sSer = "Data Source=" + str2 + ";"
sCon = sPro + sDsn + sSer
str3 = "fadianliang" '改归档组名
str4 = "yanfalou01"
sStartDay ="2013-10-01" '改日期
sEndDay = "2014-08-09"时间可以任意设置
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
Dim val1
sSql = "TAG:R,'" + str3 + "\" + str4 + "','" + sStartDay + " 00:00:00.000'," + "'" + sEndDay + " 17:00:00.000'"
oCOm.CommandText = sSql
Set oRs = oCOm.Execute
oRs.MoveLast
val1 =oRs.Fields(2).Value
仅供参考,不懂得留言。