Город МОСКОВСКИЙ
00:11:00

CODE CONNECT BETWEEN WINCC AND SQL SERVER

Аватар
MySQL Советы для администраторов
Просмотры:
29
Дата загрузки:
08.12.2023 15:14
Длительность:
00:11:00
Категория:
Лайфстайл

Описание

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

Рекомендуемые видео