wincc怎么做数据库_WINCC与数据库连接
近來做了一個
WinCC
與數(shù)據(jù)庫連接的程序,功能如下:
1
、要求用戶輸入“實驗?zāi)康摹焙汀皩嶒炄掌凇?#xff0c;點擊“建立表格”,則在數(shù)據(jù)
庫中創(chuàng)建了以“實驗?zāi)康?/p>
+
時間”為名字的表
2
、點擊“連接數(shù)據(jù)庫”連接上數(shù)據(jù)庫,并開始寫入數(shù)據(jù)
3
、點擊“斷開數(shù)據(jù)庫”則停止記錄數(shù)據(jù)
做法:
通過一個數(shù)字量來判斷數(shù)否記錄數(shù)據(jù),
若該數(shù)字量是
1
則開始記錄數(shù)據(jù),
否則停
止。記錄數(shù)據(jù)的時間間隔是
1
秒
在”建立表格“鍵入代碼:
Dim?objConnection
Dim?strConnectionString
Dim?strSQL
Dim?objCommand
Dim?objscreen
Dim?obj_item
Dim?obj_item1
Dim?biaoming
Dim?shjian
Set?shjian?=?HMIRuntime.Tags("shjian")
Set?biaoming?=?HMIRuntime.Tags("biaoming")
Set?objscreen=HMIRuntime.Screens("database")
Set?obj_item=objscreen.ScreenItems("IOField1")
Set?obj_item1=objscreen.ScreenItems("IOField")
注:不同界面的不同對象
的引用方法
If?shjian.Read=?""?Or?biaoming.Read=?""?Then
MsgBox?"Please?enter?the?table?name?and?date!"
Else
strConnectionString?=?"Provider=MSDASQL;DSN=t;UID=;PWD=;"
strSQL="create?table?"?&?Trim(?obj_item.OutputValue?)?&
Trim(?obj_item1.OutputValue?)?&?"
(name
varchar(64),age
varchar(20))"
注:這是兩個輸入控件的連接方法(建
立的表格)
總結(jié)
以上是生活随笔為你收集整理的wincc怎么做数据库_WINCC与数据库连接的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【几何/分治】【最短路】【数学期望】Da
- 下一篇: 密码学-代数数论基本知识