CODE CONNECT BETWEEN WINCC AND SQL SERVER
Описание
code mình để đây, các bạn coppy về dùng nhé !
Dim objConnection, strConnectString, strSql, objCommand
Dim start_date,start_time,CL950001,CP900006,datetime 'This is the variable
start_date=FormatDateTime(Now(),0)
start_time = Now()
datetime = FormatDateTime(Now(),0) 'This is the date time
strConnectString = "Provider=MSDASQL;DSN=winccsql;UID=;PWD=;"
CL950001 = HMIRuntime.Tags("900CP001_processvalue").READ 'write the Tag into the CL950001
strSql="INSERT INTO ICA1r (start_date,start_time,CL950001,CP900006,datetime) VALUES ('" & start_date & "','" & start_time & "','" & CL950001 & "','" & CP900006 & "','" & datetime & "')"
'This is the variable in the columns SQl. This is the Tag in the WinCC where the Tag you need to save.
Set objConnection=CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnectString
objConnection.Open
Set objCommand = CreateObject("ADODB.Command")
With objCommand
.ActiveConnection = objConnection
.CommandText = strSql
End With
objCommand.Execute
Set objCommand = Nothing
objConnection.Close
Set objConnection = Nothing
End Sub
Рекомендуемые видео

![ОЗВУЧКА СЕРИАЛА 🌷 Исключение 💉 Гача Лайф - Gacha Life [Яой]](/images/video/2026-09-17/7f/3e/7f3ec0c81c7be118c7aae46719237c1b.jpg?width=640)
















