wincc 6.0 怎么样才能读到数据库中的数据?能不能那读到数据参与PLC程序的控制?望高手们能指点指点,不胜感激!发个列子更好,
邮箱:xch202@163.com
最佳答案
wincc 6.0 怎么样才能读到数据库中的数据?--------可以用脚本方法实现!
能不能那读到数据参与PLC程序的控制?-----可以!
给你段脚本看看:
Dim sPro
Dim sDsn
Dim sSer
Dim sCon
Dim sSql
Dim oRs
Dim conn
Dim oCom
Dim oItem
Dim m, n, s
Dim hourdate
Dim secdate
Dim k
Dim oList
Set oList = ScreenItems("Para_Listview")
oList.View =3
oList.ListItems.Clear
''[RED]WinCCOLEDBProvider[/RED]
sPro = "Provider=WinCCOLEDBProvider.1;"
sDsn = "Catalog=CC_extrudin_07_09_12_14_02_42R;"
sSer = "Data Source=.\WinCC"
sCon = sPro + sDsn + sSer
'sSql = "TAG:R,'ProcessvalueArchive\NewTag','0000-00-00 00:00:00.000','0000-00-01 00:00:00.000'"
sSql = "SELECT * FROM UA#JobData"
MsgBox "Open with:" & vbCr & sCon & vbCr & sSql & vbCr
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = sCon
conn.CursorLocation = 3
conn.Open
Set oRs = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command")
oCom.CommandType = 1
Set oCom.ActiveConnection = conn
oCom.CommandText = sSql
Set oRs = oCom.Execute
提问者对于答案的评价:
看不懂,还是谢谢了
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc270236.html