讀寫wincc中的sql數(shù)據(jù)
鄭志武
發(fā)布于2012-12-20 17:27
622
0
標簽:
wincc中如何通過寫腳本的方式將數(shù)據(jù)存儲到sql數(shù)據(jù)庫中,這個腳本好寫嗎?誰能提供一份腳本模版啊,謝謝!
問題補充:
麻煩你還發(fā)個寫到sql的程序過來好嗎?沒有sql程序的經(jīng)驗,真心不會啊
佳答案
wincc的sql不是普通的sql,它是壓縮的,可以存儲更多的數(shù)據(jù),查詢可以實現(xiàn),如果你要向里面插入數(shù)據(jù),我個人認為你還是利用其他的數(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'查看是否到記錄結束
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