歡迎回到技成培訓(xùn)網(wǎng)
技成培訓(xùn)網(wǎng)
電工題庫寶典
技成電工課堂
PLC練習(xí)題
技成PLC課堂
變頻器故障查詢
技成PLC學(xué)吧
伺服驅(qū)動(dòng)故障查詢
技成PLC網(wǎng)校
wincc中如何通過寫腳本的方式將數(shù)據(jù)存儲(chǔ)到sql數(shù)據(jù)庫中,這個(gè)腳本好寫嗎?誰能提供一份腳本模版啊,謝謝!
問題補(bǔ)充:
麻煩你還發(fā)個(gè)寫到sql的程序過來好嗎?沒有sql程序的經(jīng)驗(yàn),真心不會(huì)啊
佳答案
wincc的sql不是普通的sql,它是壓縮的,可以存儲(chǔ)更多的數(shù)據(jù),查詢可以實(shí)現(xiàn),如果你要向里面插入數(shù)據(jù),我個(gè)人認(rèn)為你還是利用其他的數(shù)據(jù)庫或者excel等保存這些數(shù)據(jù),查詢起來就簡單多了。查詢數(shù)據(jù)庫:
'創(chuàng)建到數(shù)據(jù)庫的鏈接
'創(chuàng)建數(shù)據(jù)庫聯(lián)接
spro="provider=winccoledbprovider.1;"
sdsn="catalog="&tagdnsname.value&";"
sser="datasource=.wincc"
scon=spro+sdsn+sser
setconn=createobject("adodb.connection")
conn.connectionstring=scon
conn.cursorlocation=3
conn.open
ssql="tag:r,('test estdata'),'"&utc_begin_time&"','"&utc_end_time&"'"
msgbox"openwith:"&vbcr&scon&vbcr&ssql&vbcr
setors=creatobject("adodb.recordset")
setocm=creatobject("adodb.command")
ocm.commandtype=1
setocm.activeconnection=conn
ocom.commandtext=ssql
'讀取數(shù)據(jù)
setors=ocm.execute
m=ors.recordcount
count_data=0.0
sum_data=0.0
if(m>0)then
dowhilenotors.eof'查看是否到記錄結(jié)束
sum=sum+ors.fields(0).value
count_data=count_data+1.0
ors.movenext
loop
elsemsgbox"沒有查詢到數(shù)據(jù)............."
item.enabled=true
setors=nothing
conn.close
setconn=nothing
endif
setors=nothing
conn.close
setconn=nothing
若有收獲,就點(diǎn)個(gè)贊吧!
微信掃一掃分享
閱讀與本文標(biāo)簽相同的文章