我刚接触wincc,现在要在wincc里做一个月报表,需要每天在当天结束时将数据库中的日表里的每项数据读出来求平均值再写入月表里,现在没办法实现数据读取,可能是连接不到数据库,
Dim objConnection
Dim strConnectionString
Dim opertime,device,command
Dim strSQL
Dim objCommand
Dim DsnStr
Dim dt
Dim PV1,PV2,PV3,PV4,PV5,PV6,PV7,PV8,PV9,PV10,PV11,PV12,PV13,PV14,PV15,PV16
Dim iday,imonth,iyear,ihour
DsnStr="CC_sheet"
strConnectionString = "Provider=MSDASQL;DSN="&DsnStr&";database=repotrdb;UID=sa;PWD=;"
dt=Now() '系统时间
imonth=Month(dt)
iyear=Year(dt)
iday=Day(dt)
ihour=Hour(dt)
pv4="select influx from daydata where zyear="& iyear & " And zmonth= " &imonth & "And zday=" & iday & " "
MsgBox pv4
'Set objConnection = CreateObject("ADODB.Connection")
'objConnection.ConnectionString = strConnectionString
objConnection.Open
Set objCommand = CreateObject("ADODB.Command")
HMIRuntime.Trace strsql
objCommand.ActiveConnection = objConnection
objCommand.CommandText = strSQL
objCommand.Execute
objcomand
Set objCommand = Nothing
objConnection.Close
Set objConnection = Nothing
SQL语句在报表编辑器中的动态表格中测试是可以的
哪位高手知道的指点一下,急~~~~~