Connection Method of WinCC Database

Source: Internet
Author: User
Tags dsn sybase database

 

WinCCHow to exchange data with local databases (such as SQL Server and Oracle?
The following tests describe how to connect to a remote database:
Topic One: ODBC
Testing environment:
Primary PC with a WinCC, this PC, we named is server.
Secondary PC with a access DB, this PC, we named is client.
Server pc and client PC is connected by Ethernet.
Test step:
1. The server pc and the client PC must config the DB server option. This is a very
Important ODBC configuration step.
Control Panel-> SIMATIC workstation-> workstation configuration-> TCP/IP
Configuration for multiple node systems-> select the DB server option.
2. At the server pc node, active the WinCC project but do not running this project (this action
Is only for the first time ODBC configuration at the client PC). WinCC will build two ODBC
Driver connections automatically, one is for rt database and the other is for RC database.
For example: "CC_u1_01-04-12_15: 36: 08r", "CC_u1_01-04-12_15: 36: 08 ".
All of the jobs is over at the server pc node.
3. At the client PC node, open the contol panel folder and select the "Sybase SQL
Anywhere5.0 "Driver for configuration ODBC driver.
Data Source Name: CC_u1_01-04-12_15: 36: 08r (be named at the server pc node .)
User ID: DBA
Password: SQL
Server Name: bjadlijs_n (server pc node computer name)
Database Name: CC_u1_01-04-12_15: 36: 08r (the same as data source name)
Database File: // bjadlijs/wincc50_project_u1/u1rt. dB (the "wincc50_project_u1" is
Share directory by WinCC automatically and the "u1rt. DB" is the WinCC RT database name.
You 'd better search the "u1rt. DB" file via the Browse button .)
At this time, we completed the ODBC configuration.
4. At the server pc node, running the WinCC Project (don't forget to select the tag Logging
Option in the start up page, at the same time you coshould creat a form by user archive only
Test .)
5. At the client PC node, you can open an access and import or link forms via an ODBC
Driver that is builded at the step three.
• How to Use third-party software (such as VB) to operate the Sybase Database of WinCC?
Through ODBC, you can use third-party software to operate databases (VB, Vc, and Delphi ).
Dao, rdo, and ADO methods are simple routines for accessing WinCC RT databases. The development environment is VB6.0:
Public wsodbc as workspace
Public cnodbc as connection
Public rsodbc as recordset
'Dao Method
Public sub loadodbcdata ()
Set wsodbc = dbengine. CREATEWORKSPACE ("odbc_ws", "admin", "", dbuseodbc)
Set cnodbc = wsodbc. openconnection ("connection1 ",,,_
& Quot; ODBC; uid = DBA; Pwd = SQL; DSN = CC_416_01-04-17_00: 54: 00r & quot ")
Set rsodbc = cnodbc. openrecordset ("PVDF # HD # tankvalue_arc # tanklevel2 ")
'Pde # HD # tankvalue_arc # tanklevel2 is Rt database Sample Table
'Dbgrid1. Text = rsodbc
T1.text = rsodbc. Fields ("T ")
T2.text = rsodbc. Fields ("v ")
Rsodbc. Close
Cnodbc. Close
Wsodbc. Close
End sub
'Rdo Method
Public sub rdodata ()
Dim RS as rdoresultset
Dim cn as new rdoconnection
Dim SQL as string
Set Cn = new rdoconnection
With Cn
. Connect = "uid = DBA; Pwd = SQL; DSN = demo1 ;"
'Demo1 is a manully created odbc dsn of Sybase Database
. Establishconnection rddrivernoprompt, false
End
SQL = "select * From contact"
Set rs = cn. openresultset (SQL, rdopenkeyset ,_
Rdconcurreadonly, rdasyncenable + rdexecdirect)
T3.text = Rs! City
T4.text = Rs! ID
End sub
'Ado Method
Public sub adodata ()
Dim RS as ADODB. recordset
Set rs = new ADODB. recordset
Rs. Open "select * From contact order by ID ",_
"Uid = DBA; Pwd = SQL; DSN = demo1 ;"
T5.text = Rs! ID
T6.text = Rs! City
End sub
It is worth noting that
1. In office suites, you cannot use rdo to access the ODBC database, because Microsoft does not provide
Rdo library functions.
2. ODBC user DSN is automatically generated during project startup without user intervention
3. There are two databases, one is the config database, which stores the configuration information, and the other is the real-time (RT) database,
It stores process data, including historical and alarm information. More operations are performed on the RT database.
In addition to the specific structure of the database, you can use the WinCC installation directory (for example
In C:/Siemens/common/sqlany/scview.exe), view the specific table and field. You can also
Use isql.exe in its directory to query specific records using SQL statements
• How does WinCC provide external data as a data provider (how to open its internal data )?
There are mainly the following methods:
1 .. Use ODBC for local/remote database connection (as described above );
2 .. Process data connection through OPC in local/remote mode, including connection between WinCC and
OPC communication between winac and other third-party software supporting OPC and the OPC
Server/client software communications;
3. Exchange Process data with the local machine through DDE and provide data to remote PCs through NETDDE;
4 .. Communicate with Excel through OLE, use VBA in Excel, create a WinCC object, and use its
The getvalue and setvalue methods can exchange data with WinCC. (For details, see WinCC electronic documentation.
Config2_c.pdf file ). The following is a VBA routine in Excel:
Private sub commandbutton#click ()
Dim MCP as object
Dim VaR as string
Dim value as Variant
Dim cell as Variant
Dim I as integer
Set MCP = Createobject ("WinCC-runtime-project ")
Cell = "C3"
I = 1
Do while not range (cell) = ""
Var = range (cell)
Value = MCP. getvalue (VAR)
Range ("D" & 2 + I). value = Value
Cell = "C" & I + 3
I = I + 1
Loop
End sub
Private sub commandbutton2_click ()
Dim MCP as object
Dim VaR as string
Dim value as Variant
Dim cell as Variant
Dim I as integer
Dim Bret as integer
Set MCP = Createobject ("WinCC-runtime-project ")
Cell = "C3"
I = 1
Do while not range (cell) = ""
Var = range (cell)
Value = range ("e" & 2 + I). Value
Bret = MCP. setvalue (VAR, value)
Cell = "C" & I + 3
I = I + 1
Loop
End sub
5. It can be accessed using the simatic dmc ActiveX control provided by WinCC.
A simple example of WinCC process data is as follows:
Dim tagval as Variant
Dim mystate as long
Dim mydmc as object
'Write the WinCC tag value named "newtag"
'Tagval is the value which will be written in WinCC
Private sub commandementclick ()
Dmc1.connect mydmc
Dmc1.write "newtag", 100, tagval
Dmc1.disconnect
End sub
'Read the WinCC tag value named "newtag"
'Tagval will get the tag value from WinCC
Private sub commandementclick ()
Dmc1.connect mydmc
Dmc1.read "newtag", 100, tagval, mystate
Dmc1.disconnect
End sub

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.