sxd566
級(jí)別: *
|
我剛接觸wincc,現(xiàn)在要在wincc里做一個(gè)月報(bào)表,需要每天在當(dāng)天結(jié)束時(shí)將數(shù)據(jù)庫(kù)中的日表里的每項(xiàng)數(shù)據(jù)讀出來(lái)求平均值再寫(xiě)入月表里,現(xiàn)在沒(méi)辦法實(shí)現(xiàn)數(shù)據(jù)讀取,可能是連接不到數(shù)據(jù)庫(kù), 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() '系統(tǒng)時(shí)間 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語(yǔ)句在報(bào)表編輯器中的動(dòng)態(tài)表格中測(cè)試是可以的 哪位高手知道的指點(diǎn)一下,急~~~~~ |
---|---|
|