Wincc database SQLSERVER

Source: Internet
Author: User
In the WINCC graphic editor, select an event from the properties of the input domain, select the release action on the keyboard, and write the following code in the Action Code box: Dimconn, rsDimstrsqlDimaaHMIRuntime. tags (datavariable ). readSetconnCreateObject (adodb. connection) SetrsCreateObje

In the WINCC graphic editor, select an event from the properties of the input domain, select the release action on the keyboard, and write the following code in the Action Code box: Dim conn, rs Dim strsql Dim a = HMIRuntime. tags (datavariable ). read Set conn = CreateObject (adodb. connection) Set rs = CreateObje

WINCC write Database
In the WINCC graphic editor, select an event from the input field attributes, select the release action on the keyboard, and write the following code in the Action Code box:
Dim conn, rs
Dim strsql
Dim
A = HMIRuntime. Tags ("datavariable"). Read
Set conn = CreateObject ("adodb. connection ")
Set rs = CreateObject ("adodb. recordset ")
Conn. Provider = "sqloledb"
Conn. open "SERVER = Yang-PC \ WINCC; uid = sa; pwd = sa; database = datasavetest"
Strsql = "insert into tt_ch (TagValue) VALUES ('" & &"')"
Set rsw.conn.exe cute (strsql)

Conn. close
Set rs = Nothing

Set conn = Nothing

End If

In this way, real-time WINCC data can be written to SQL SERVER.

WINCC read database

Dim conn, rs
Dim strsql
Dim temp1, temp2

Set conn = CreateObject ("adodb. connection ")
Set rs = CreateObject ("adodb. recordset ")
Conn. Provider = "sqloledb"
Conn. open "SERVER = YANG-PC \ WINCC; uid = sa; pwd = 1988525; database = datasavetest"

Strsql = "select * from table_1"
Set rsw.conn.exe cute (strsql)

Rs. movenext can read the next row of the dataset and perform operations using other attributes of the dataset.

Temp1 = rs. Fields (0). value' take the Value of the first column

'Temp1 = rs ("text") Get the value of the field "text" from the dataset

Set temp2 = HMIRuntime. Tags ("textdataAuto ")
Temp2.Read
Temp2.Write temp1

Conn. close
Set rs = Nothing
Set conn = Nothing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.