wincc连接mysql数据库说明_wincc 数据库的连接方法
WinCC中如何与本地数据库(如SQL
SERVER、ORACLE)进行数据交换?以下的测试将说明如连接远程的数据库:
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 a
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 could creat a
form by user archive only for
test.)
5. At the client PC node, you could open an Access and import or
link forms via an ODBC
driver that is builded at the step three.
•
如何正确使用第三方软件(如VB)对WinCC的SYBASE数据库进行操作,应注意什么细节?
通过ODBC,可以使用第三方软件对数据库进行操作(VB,VC,DELPHI).下面是分别使用
DAO,RDO和ADO方法对WinCC的RT数据库访问的简单例程,开发环境为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", , ,
_
"ODBC;UID=DBA;PWD=SQL;DSN=CC_416_01-04-17_00:54:00R")
Set rsODBC =
cnODBC.OpenRecordset("PDE#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 With
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
值得注意的是
1.在OFFICE套件中,不能使用RDO访问ODBC数据库,因为MICROSOFT没有对VBA提供
RDO的库函数.
2.ODBC的USER DSN 是在工程启动的过程中自动生成的,无需用户干预
3.有两个数据库,一个是CONFIG 数据库,里面存放的是组态信息,另一个是实时(RT)数据库,
里面存放的是过程的数据,包括历史和报警等信息,用户更多的将是对RT库的操作;如果不清
除数据库的具体结构,可以使用WINCC安装目录 ( 例如
c:/siemens/common/sqlany/scview.exe )
下的scview.exe查看具体的TABLE及字段,还可以
用其目录下的isql.exe工具用SQL语句查询具体的记录
•
WinCC怎样作为数据提供者向外提供数据(怎么开放其内部数据)?
主要有以下几种方法:
1。.通过ODBC进行local/remote方式的数据库的连接(上面已经叙述);
2。.通过OPC进行local/remote方式的过程数据的连接,包括WINCC之间的连接和与
WINAC之间的OPC通讯,以及其他支持OPC的第三方软件和用户自行开放的OPC
SERVER/CLIENT软件通讯;
3。 通过DDE与本机交换过程数据,通过NETDDE向远方PC提供数据;
4。.通过OLE与EXCEL通讯,在EXCEL中使用VBA,创建WINCC对象,使用其
GetValue和SetValue方法可以与WINCC交换数据。(具体见WINCC电子文档
CONFIG2_C.PDF文件)。下面是EXCEL中的VBA例程:
Private Sub CommandButton1_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。可以使用 WINCC提供的SIMATIC DMC ActiveX控件存取
WINCC过程数据,简单例程如下:
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 Command1_Click()
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 Command1_Click()
Dmc1.Connect myDmc
Dmc1.Read "NewTag",100,tagVal,myState
Dmc1.Disconnect
End Sub
wincc连接mysql数据库说明_wincc 数据库的连接方法相关推荐
- php mysql 自动重连_PHP连接MySql闪断自动重连的方法
if(isset(self::$_instance) && !empty(self::$_instance)){ return self::$_instance; } 闪断后,因为 s ...
- navicat for mysql 1045错误,navicat连接mysql时出现1045错误的解决方法
navicat连接mysql时出现1045错误的解决方法 navicat for MySQL 连接本地数据库出现1045错误 如下图: 查了很多资料,意思是说mysql没有授权远程连接,也就是权限不够 ...
- Java web连接数据库实现登录功能 ; jsp连接MySQL或SQL server数据库的jar包也在这里哦!
[深夜放毒,记录生活^_^] 学了HTML之后 , 一直想写一个能够实现登录功能的小网页 ,终于--现在开始学习数据库,经过查阅资料,创建了很简单的一个java web小项目来实现登陆操作,界面不 ...
- php连接mysql数据没反应_php无法连接mysql数据库的正确解决方法
{"moduleinfo":{"card_count":[{"count_phone":1,"count":1}],&q ...
- C++连接mysql的两种方式(ADO连接和mysql api连接)
一.ADO连接mysql 1.安装mysql-5.5.20-win32.msi和mysql-connector-odbc-5.3.4-win32.msi(一般两个安装程序要匹配,否则可能连接不上) ...
- mysqlfront连接MySQL错误,使用MySQL-Front连接mysql的时候发生的错误解决方法
在使用MySQL-Front连接mysql的时候发生的这个错误 ERROR 1130: Host 192.168.88.160 is not allowed to co ...
- powerdesigner连接mysql,并导出其数据模型的方法
http://hi.baidu.com/ryb_bobo/item/05a21dcf2e123f3199b49864 1.powerdesigner连接mysql,需要配置数据源,下载MyODBC-3 ...
- PHP连接MYSQL出现乱码的原因与解决方法
解决MySql数据库乱码的一个首要前提是保证 数据库+数据表+前端显示 编码一致,国内项目一般统一设定为GB2312或GBK,而国际化项目则一般使用utf8. 另外,字符集设定完毕之后记得重启目标机M ...
- mysql错误编号2058_SQLyog连接MySQL时出现的2058错误解决方法
配置新连接报错:错误号码 2058,分析是 mysql 密码加密方法变了. 解决方法:windows 下cmd 登录 mysql -u root -p 登录你的 mysql 数据库,然后执行这条SQL ...
- Navicat 连接 MySql 报错2059时的解决方法
My报错2059时的操作方法 当你使用navicat连接MySQL 的时候,会出现报错2059.如下图所示: 按照如下操作: 1:在电脑中搜索 MySQL 8.0 Command Line Clien ...
最新文章
- Python 面向对象、封装
- Linux下快速静态编译Qt以及Qt动态/静态版本共存
- Http Hijacker
- tomact错误日志是那个_如何查看tomcat启动异常日志详情
- *【CodeForces - 202C 】Clear Symmetry (思维,找规律,特判)
- 第四期《Summer Tree》 已经整理完毕
- SQL Server 2012 Always ON笔记
- 简析LIVE555中的延时队列
- mysql索引为什么使用B+tree,InnoDB与MyISAM 的区别
- java queue 清空_java swing清除事件队列
- ARC075 F.Mirrored
- [转]mysql中int、bigint、smallint 和 tinyint的区别与长度的含义
- mysql查询忽略字符编码是什么_MySQL 查询不区分大小写的问题以及编码格式问题...
- wireshark使用教程
- Win7如何开启Aero特效?
- CSS 导入方式 选择器
- 迅雷下载显示服务器响应超时?
- hp刀片服务器装系统,hp刀片服务器安装系统教程精选.docx
- GPUImage--美颜滤镜GPUImageBeautifyFilter
- 最新!魅族、魅蓝手机安装Xposed框架的最新方法!亲测有用!