你现在位置:首页>技术论文>软件知识>正文
wincc数据库的连接方法
日期:2009-10-16 14:19:52 点击:
来源:本站整理
作者:
点击【】放大字体.
? WinCC 中如何与本地数据库(如SQL SERVER、ORACLE)进行数据交
WWW_PL※CJS_COM-PLC-技.术_网

换?
WWW_PLC※JS_COM-PmLC-技.术_网

以下的测试将说明如连接远程的数据库:
plcjs.技.术_网

Topic One: ODBC
W1WW_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 very
WW.W_PLCJS_COM-PLC-技.术_网

important ODBC configuration step.
P.L.C.技.术.网——可编程控制器技术门户

Control Panel -> SIMATIC Workstation -> Workstation Configuration -> TCP/IP
WWW_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 action
WWW_PLCJ-S_COM-PLC-技.术_网(可-编程控-制器技术-门户)

is only for the first time ODBC configuration at the client PC) . WinCC will build two ODBC
WWW_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 SQL
WWW_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: DBA
WW.W_PLC※JS_C,OM-PL,C-技.术_网

Password: SQL
WW.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: WinCC50_Project_u1/u1RT.db">\\Bjadlijs\WinCC50_Project_u1\u1RT.db (the "WinCC50_Project_u1" is a
WWW_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 Logging
WWW※PLCJS_COM-PL#C-技.术_网(可编※程控※制器技术门户)

option in the start up page, at the same time you could creat a form by user archive only for
WWW_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 ODBC
P_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 Workspace
P_L_C_技_术_网——可——编——程——控-制-器-技——术——门——户

Public cnODBC As Connection
WWW_PLC※JS_COM-PLC-技.术_网(可编程控※制器技术门户)

Public rsODBC As Recordset
WWW_PLCJS※COM-PLC-技×术_网(可编程控※制器技术门户)

‘DAO method
WW.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 table
W1WW_P4LCJS_COM-PLC-技.术_网

DBGrid1.Text = rsODBC
WWW_PLCJS@_COM%-PLC-技.术_网

T1.Text = rsODBC.Fields("T")
W1WW_P4LCJS_COM-PLC-技.术_网

T2.Text = rsODBC.Fields("V")
WWW_P※LCJS_COM-PLC-)技.术_网

rsODBC.Close
WW.W_PLC※JS_C,OM-PL,C-技.术_网

cnODBC.Close
——可——编——程——控-制-器-技——术——门——户

wsODBC.Close
WW.W_PLC※JS_C,OM-PL,C-技.术_网

End Sub
WWW_PLCJS※COM-PLC-技.术_网(可※编程控※制器技术门户)

’RDO method
——可——编——程——控-制-器-技——术——门——户

Public Sub RDOData()
——可——编——程——控-制-器-技——术——门——户

Dim rs As rdoResultset
WWcW_PLCJS_COM-PLC-技.术_网

Dim cn As New rdoConnection
W1WW_P4LCJS_COM-PLC-技.术_网

Dim SQL As String
WWW_PLCJS@_COM%-PLC-技.术_网

Set cn = New rdoConnection
WWW_PL※CJS_COM-PLC-技.术_网

With cn
WWW_PLCJS※COM-PLC-技.术_网(可※编程控※制器技术门户)

.Connect = "uid=DBA;pwd=SQL;DSN=demo1;"
WWW.PLCJS.COM——可编程控制器技术门户

‘demo1 is a manully created ODBC DSN of Sybase database
P_L_C_技_术_网——可——编——程——控-制-器-技——术——门——户

.EstablishConnection rdDriverNoPrompt, False
WWW_PLCJS_COM-PLC-技.术_网

End With
WWW_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!city
WWcW_PLCJS_COM-PLC-技.术_网

T4.Text = rs!id
WWW_PLCJS_COM-PLC-技.术_网

End Sub
WWW_PLCJS※COM-PLC-技.术_网(可※编程控※制器技术门户)

‘ADO method
WWW_PLC※JS_COM-PmLC-技.术_网

Public Sub AdoData()
WWW_P※LCJS_COM-PLC-)技.术_网

Dim rs As ADODB.Recordset

本新闻共2页,当前在第11 2  
WWW_PLC※JS_COM-PmLC-技.术_网

评论内容
载入中...
相关文章
商城相关
相关下载
博客相关
论坛相关
P
L
C



|










|


P
L
C









·最新招聘信息
·最新求职信息
·推荐产品
·推荐厂商
深圳秦合源科技有限公司 
   深圳市秦合源科技有限公司是国内领先的规模较大品种齐全的称重传感器(Loadce......
广州汇巨自动化设备有限公司 
   广州汇巨自动化设备有限公司是一家专业工业自动化产品和自动化设备开发、维修改造、电......
深圳联脉电子有限公司 
   公司自1998年创立以来,一直致力于工业控制产品的研发、制造、销售,目前有机房监......
北京力天昭阳科技发展有限公司 
   北京力天昭阳科技发展有限公司(PekingPowerSkyScience&......
东莞市友诚自动化 
   本公司专业代理台湾永宏、台达PLC、HITECH人机、特价供应文本显示器MD20......
深圳市爱威轮实业有限公司 
   爱威轮实业对广大用户的技术支持与服务,贯穿于与客户接触的每一个环节中,渗透在每一......
·栏目热门排行
·站内热门排行
载入中。。
报告错误·关于我们· 用户帮助· 联系我们 · 友情链接· 本站服务 · 合作伙伴 · 版权声明· 招聘信息 · 投搞指南

迅闻自动化工程部声明如下:
旗下网站:PLC技术网(www.plcjs.com)-可编程控制器技术门户
网站备案号:粤ICP备17165530号
网站法律顾问:ITLAW-庄毅雄律师
法律保护:PLC技术网,迅闻电子,plcjs.com,plcjs.net,plcjs.cn等字样

Copyright 2010-2015. All rights reserved. 

51La