? WinCC 中如何与本地数据库(如SQL SERVER、ORACLE)进行数据交WWW_PL※CJS_COM-PLC-技.术_网
换?WWW_PLC※JS_COM-PmLC-技.术_网
以下的测试将说明如连接远程的数据库:plcjs.技.术_网
Topic One: ODBCW1WW_P4LCJS_COM-PLC-技.术_网
Testing environment:WW.W_PLC※JS_C,OM-PL,C-技.术_网
Primary PC with a WinCC, This PC, we named is Server.——可——编——程——控-制-器-技——术——门——户
Secondary PC with a Access DB, This PC, we named is Client.WWW_PL※CJS_COM-PLC-技.术_网
Server PC and Client PC is connected by Ethernet.WWW_P※LCJS_COM-PLC-)技.术_网
Test step:WW.W_PLC※JS_C,OM-PL,C-技.术_网
1. The Server PC and the Client PC must config the DB server option. This is a veryWW.W_PLCJS_COM-PLC-技.术_网
important ODBC configuration step.P.L.C.技.术.网——可编程控制器技术门户
Control Panel -> SIMATIC Workstation -> Workstation Configuration -> TCP/IPWWW_PLCJS_COM-PLC-技.术_网
Configuration for Multiple Node Systems -> select the DB server option.WW.W_PLC※JS_C,OM-PL,C-技.术_网
2. At the server PC node, active the WinCC project but do not running this project(This actionWWW_PLCJ-S_COM-PLC-技.术_网(可-编程控-制器技术-门户)
is only for the first time ODBC configuration at the client PC) . WinCC will build two ODBCWWW_PLCJS※COM-PLC-技×术_网(可编程控※制器技术门户)
driver connections automatically, one is for RT Database and the other is for RC Database.WW.W_PLCJS_COM-PLC-技.术_网
For example: "CC_u1_01-04-12_15:36:08R","CC_u1_01-04-12_15:36:08".WWW※PLCJS_COM-PL#C-技.术_网(可编※程控※制器技术门户)
All of the jobs is over at the server PC node.WWW.PLCJS.COM——可编程控制器技术门户
3. At the client PC node, open the contol panel folder and select the "Sybase SQLWWW_PLCJS※COM-PLC-技×术_网(可编程控※制器技术门户)
Anywhere5.0" driver for configuration ODBC Driver.P.L.C.技.术.网——可编程控制器技术门户
Data Source Name:CC_u1_01-04-12_15:36:08R (be named at the server PC node.)W1WW_P4LCJS_COM-PLC-技.术_网
User ID: DBAWW.W_PLC※JS_C,OM-PL,C-技.术_网
Password: SQLWW.W_PLCJS_COM-PLC-技.术_网
Server Name: BJADLIJS_N (Server PC Node computer name)plcjs.技.术_网
Database Name: CC_u1_01-04-12_15:36:08R (the same as Data Source Name)WWcW_PLCJS_COM-PLC-技.术_网
Database File: \\Bjadlijs\WinCC50_Project_u1\u1RT.db (the "WinCC50_Project_u1" is aWWW_PL※CJS_COM-PLC-技.术_网
share directory by WinCC automatically and the "u1RT.db" is the WinCC RT database name.WWW※PLCJS_COM-PL#C-技.术_网(可编※程控※制器技术门户)
youd better search the "u1RT.db" file via the Browse button.)WW.W_PLCJS_COM-PLC-技.术_网
At this time, we completed the ODBC configuration.WWW_PLCJS_COM-PLC-技.术_网
4. At the server PC node, Running the WinCC project( Dont forget to select the Tag LoggingWWW※PLCJS_COM-PL#C-技.术_网(可编※程控※制器技术门户)
option in the start up page, at the same time you could creat a form by user archive only forWWW_P※LCJS_CO※M-PLC-技-.术_网
test.)P.L.C.技.术.网——可编程控制器技术门户
5. At the client PC node, you could open an Access and import or link forms via an ODBCP_L_C_技_术_网——可——编——程——控-制-器-技——术——门——户
driver that is builded at the step three.WWW_PLC※JS_COM-PmLC-技.术_网
? 如何正确使用第三方软件(如VB)对WinCC的SYBASE数据库进行操作,WWW_PLCJS_COM-PLC-技.术_网
应注意什么细节?WWW_P※LCJS_CO※M-PLC-技-.术_网
通过ODBC,可以使用第三方软件对数据库进行操作(VB,VC,DELPHI).下面是分别使用P.L.C.技.术.网——可编程控制器技术门户
DAO,RDO和ADO方法对WinCC的RT数据库访问的简单例程,开发环境为VB6.0:——可——编——程——控-制-器-技——术——门——户
Public wsODBC As WorkspaceP_L_C_技_术_网——可——编——程——控-制-器-技——术——门——户
Public cnODBC As ConnectionWWW_PLC※JS_COM-PLC-技.术_网(可编程控※制器技术门户)
Public rsODBC As RecordsetWWW_PLCJS※COM-PLC-技×术_网(可编程控※制器技术门户)
‘DAO methodWW.W_PLC※JS_C,OM-PL,C-技.术_网
Public Sub LoadODBCData()WWW_PLCJ-S_COM-PLC-技.术_网(可-编程控-制器技术-门户)
Set wsODBC = DBEngine.CreateWorkspace("ODBC_ws", "Admin", "", dbUseODBC)P_L_C_技_术_网——可——编——程——控-制-器-技——术——门——户
Set cnODBC = wsODBC.OpenConnection("Connection1", , , _WWW_PLCJS※COM-PLC-技×术_网(可编程控※制器技术门户)
"ODBC;UID=DBA;PWD=SQL;DSN=CC_416_01-04-17_00:54:00R")WWW_PLCJS_COM-PLC-技.术_网
Set rsODBC = cnODBC.OpenRecordset("PDE#HD#TankValue_Arc#TankLevel2")WWW_PLC※JS_COM-PmLC-技.术_网
‘PDE#HD#TankValue_Arc#TankLevel2 is RT database sample tableW1WW_P4LCJS_COM-PLC-技.术_网
DBGrid1.Text = rsODBCWWW_PLCJS@_COM%-PLC-技.术_网
T1.Text = rsODBC.Fields("T")W1WW_P4LCJS_COM-PLC-技.术_网
T2.Text = rsODBC.Fields("V")WWW_P※LCJS_COM-PLC-)技.术_网
rsODBC.CloseWW.W_PLC※JS_C,OM-PL,C-技.术_网
cnODBC.Close——可——编——程——控-制-器-技——术——门——户
wsODBC.CloseWW.W_PLC※JS_C,OM-PL,C-技.术_网
End SubWWW_PLCJS※COM-PLC-技.术_网(可※编程控※制器技术门户)
’RDO method——可——编——程——控-制-器-技——术——门——户
Public Sub RDOData()——可——编——程——控-制-器-技——术——门——户
Dim rs As rdoResultsetWWcW_PLCJS_COM-PLC-技.术_网
Dim cn As New rdoConnectionW1WW_P4LCJS_COM-PLC-技.术_网
Dim SQL As StringWWW_PLCJS@_COM%-PLC-技.术_网
Set cn = New rdoConnectionWWW_PL※CJS_COM-PLC-技.术_网
With cnWWW_PLCJS※COM-PLC-技.术_网(可※编程控※制器技术门户)
.Connect = "uid=DBA;pwd=SQL;DSN=demo1;"WWW.PLCJS.COM——可编程控制器技术门户
‘demo1 is a manully created ODBC DSN of Sybase databaseP_L_C_技_术_网——可——编——程——控-制-器-技——术——门——户
.EstablishConnection rdDriverNoPrompt, FalseWWW_PLCJS_COM-PLC-技.术_网
End WithWWW_PL※CJS_COM-PLC-技.术_网
SQL = "select * from contact"WWcW_PLCJS_COM-PLC-技.术_网
Set rs = cn.OpenResultset(SQL, rdOpenKeyset, _WWW_P※LCJS_CO※M-PLC-技-.术_网
rdConcurReadOnly, rdAsyncEnable + rdExecDirect)WWW_PLC※JS_COM-PmLC-技.术_网
T3.Text = rs!cityWWcW_PLCJS_COM-PLC-技.术_网
T4.Text = rs!idWWW_PLCJS_COM-PLC-技.术_网
End SubWWW_PLCJS※COM-PLC-技.术_网(可※编程控※制器技术门户)
‘ADO methodWWW_PLC※JS_COM-PmLC-技.术_网
Public Sub AdoData()WWW_P※LCJS_COM-PLC-)技.术_网
Dim rs As ADODB.RecordsetWWW_PLC※JS_COM-PmLC-技.术_网