当前位置: 主页 > PLC控制

WINCC利用VBS写入SQL问题

OptionExplicit
Functionaction

DimlngValue1
DimlngValue2

DimSTrSQL
DimobjCommand

strConnectionString="Provider=MSDASQL;SERVER=JIE-PC\wincc;DSN=ceshi;UID=;PWD=;database=new"

lngValue1=HMIRuntime.Tags("a").Read
lngValue2=HMIRuntime.Tags("b").Read

strSQL="INSERTINTOtest(test,test2)VALUES("&lngValue1&","&lngValue2&");"

HMIRuntime.Trace"strSQL"

SetobjConnection=CreateObject("ADODB.Connection")

objConnection.ConnectionString=strConnectionString

objConnection.Open

SetobjCommand=CreateObject("ADODB.Command")

WithobjCommand
.ActiveConnection=objConnection
.CommandText=strSQL

EndWith

objCommand.Execute

SetobjCommand=Nothing

objConnection.Close

SetobjConnection=Nothing

EndFunction
一直无法写入,ODBC已经配置并测试连接上了,VBS脚本哪里出了问题?谢谢了。

最佳答案

已解决问题:求教Wincc导出数据问题
htTP://www.ad.siemens.com.cn/service/answer/solution.aspx?Q_ID=32759&cid=1032

提问者对于答案评价:
调试出来了,谢。

  • 关注微信

猜你喜欢

微信公众号