如何wincc中使用VBS腳本讀寫SQLServer數(shù)據(jù)庫文件?
劉玉蓉
發(fā)布于2014-12-05 17:51
2865
0
標簽:
新建一個wincc項目,想要在其后臺數(shù)據(jù)庫中間建立表格,通過VBS腳本對該數(shù)據(jù)庫進行讀寫操作,該如何做?
佳答案
Dim connstr
connstr = "Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=CC_JZX_WINC_13_03_06_10_00_07R;Data Source=.WINCC;uid=sa;pwd=;"
Set MyConn = CreateObject("ADODB.Connection")
With MyConn
.ConnectionString = connstr
.CursorLocation = 3
.Open
End With
Dim strSQL
Dim rsTmp
strSQL = "數(shù)據(jù)庫操作語句"
Set rsTmp = CreateObject("ADODB.Recordset")
Set rsTmp.ActiveConnection = MyConn
With rsTmp
.CursorLocation = 3
.CursorType = 3
.LockType = 1
.Source = strSQL
.Open
End With
剛學著弄完,Persist Security Info=False;這條語句害我研究了很久,之前沒有太在意,導致遠程讀取時登錄失敗
參考資料:https://www.ad.siemens.com.cn/service/answer/tobe_solution.aspx?Q_ID=109096&cid=1032