当前位置: 主页 > PLC控制

如何wincc中使用VBS脚本读写SQLServer数据库文件?

新建一个wincc项目,想要在其后台数据库中间建立表格,通过VBS脚本对该数据库进行读写操作,该如何做?

最佳答案

DimconnSTr
connstr="Provider=SQLOLEDB.1;PersistSecurityInfo=False;InitialCatalog=CC_JZX_WINC_13_03_06_10_00_07R;DatASourCE=.\WINCC;uid=sa;pwd=;"
SetMyConn=CreateObject("ADODB.Connection")
WithMyConn
.ConnectionString=connstr
.CursorLocation=3
.Open
EndWith
DimstrSQL
DimrsTmp
strSQL="数据库操作语句"
SetrsTmp=CreateObject("ADODB.Recordset")
SetrsTmp.ActiveConnection=MyConn
WithrsTmp
.CursorLocation=3
.CursoRType=3
.LockType=1
.Source=strSQL
.Open
EndWith
刚学着弄完,PersistSecurityInfo=False;这条语句害我研究了很久,之前没有太在意,导致远程读取时登录失败
参考资料:htTP://www.ad.siemens.com.cn/service/answer/tobe_solution.aspx?Q_ID=109096&cid=1032

提问者对于答案评价:
非常感谢你的回答。
但对于“InitialCatalog=CC_JZX_WINC_13_03_06_10_00_07R”这一句我不太明白,如何知道我所做项目对应数据库名?

  • 关注微信

猜你喜欢

微信公众号