我剛接觸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語句在報表編輯器中的動態表格中測試是可以的
哪位高手知道的指點一下,急~~~~~