Option Explicit
Function action
Dim lngValue1
Dim lngValue2
Dim strSQL
Dim objCommand
strConnectionString = "Provider=MSDASQL;SERVER=JIE-PC\WINCC;DSN=ceshi;UID=;PWD=;database=new"
lngValue1 = HMIRuntime.Tags("a").Read
lngValue2 = HMIRuntime.Tags("b").Read
strSQL = "INSERT INTO test (test,test2) VALUES ("& lngValue1 & ","& lngValue2 &");"
HMIRuntime.Trace "strSQL"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set objCommand = CreateObject("ADODB.Command")
With objCommand
.ActiveConnection = objConnection
.CommandText = strSQL
End With
objCommand.Execute
Set objCommand = Nothing
objConnection.Close
Set objConnection = Nothing
End Function
一直无法写入,ODBC已经配置并测试连接上了,VBS脚本哪里出了问题?谢谢了。
最佳答案
已解决问题:求教Wincc导出数据问题
http://www.ad.siemens.com.cn/service/answer/solution.aspx?Q_ID=32759&cid=1032
提问者对于答案的评价:
调试出来了,谢。
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc218800.html