Option Explicit
Function action
Dim objconnection
Dim strconnectionstring
Dim T1,T2,T3,T4,T5,T6,T7,P1,P2,P3,P4,P5,P6,P7,F1,F2,F3,F4,F5,F6,F7,F8,L1,L2,L3
Dim strsql
Dim objcommand
Dim a
a=HMIRuntime.Tags("TIC4101.R").Read
If a>1.0 Then
strconnectionstring="Provider=MSDASQL;DSN=wincc_1;UID=;PWD=;"
T1=HMIRuntime.Tags("TIC4101.R").Read
T2=HMIRuntime.Tags("TE4102_1.R").Read
T3=HMIRuntime.Tags("TE4102_2.R").Read
T4=HMIRuntime.Tags("TE4103.R").Read
T5=HMIRuntime.Tags("TE4106.R").Read
T6=HMIRuntime.Tags("TE4107.R").Read
T7=HMIRuntime.Tags("TE6101.R").Read
P1=HMIRuntime.Tags("PT4201.R").Read
P2=HMIRuntime.Tags("PT4202.R").Read
P3=HMIRuntime.Tags("PIC4203.R").Read
P4=HMIRuntime.Tags("PIC4204.R").Read
P5=HMIRuntime.Tags("PT4206.R").Read
P6=HMIRuntime.Tags("PT4207.R").Read
P7=HMIRuntime.Tags("PT6101.R").Read
F1=HMIRuntime.Tags("FIC4301.R").Read
F2=HMIRuntime.Tags("FIC4302.R").Read
F3=HMIRuntime.Tags("FT4307.R").Read
F4=HMIRuntime.Tags("FIC5301_1.R").Read
F5=HMIRuntime.Tags("FIC5301_2.R").Read
F6=HMIRuntime.Tags("FIC5302_1.R").Read
F7=HMIRuntime.Tags("FIC5302_2.R").Read
L1=HMIRuntime.Tags("LIC4401.R").Read
L2=HMIRuntime.Tags("LT4405.R").Read
L3=HMIRuntime.Tags("LT2405.R").Read
strsql="insert into WINCC_DATA(sysdatetime,TI4101,TI4102_1,TI4102_2,TI4103,TI4106,TI4107,TI6101,PI4201,PI4202,PI4203,PI4204,PI4206,PI4207,PI6101,FI4301,FI4302,FI4307,FI5301_1,FI5301_2,FI5302_1,FI5302_2,LI4401,LI4405,LI2405) values(Now(),"&T1&","&T2&","&T3&","&T4&","&T5&","&T6&","&T7&","&P1&","&P2&","&P3&","&P4&","&P5&","&P6&","&P7&","&F1&","&F2&","&F3&","&F4&","&F5&","&F6&","&F7&","&L1&","&L2&","&L3&");"
Set objconnection=CreateObject("ADODB.Connection")
objconnection.connectionString=strconnectionstring
objconnection.Open
Set objCommand=CreateObject("ADODB.Command")
With objcommand
.ActiveConnection=objconnection
.CommandText=strsql
End With
objcommand.Execute
Set objcommand=Nothing
objconnection.Close
End If
End Function