当前位置: 主页 > PLC控制

使用DAO连接access

使用vbs程序
DimObjConnection
DimObjCommand
Dimamount
SetObjConnection=CreateObject("ADODB.Connection")
SetObjCommand=CreateObject("ADODB.Command")
ObjConnection.ConnectionTimeout=2000
ObjConnection.ConnectionSTring="DRIVER={MicrosoftAcCEssDriver(*.mdb,*.accdb)};DBQ=F:\amount.accdb"
ObjConnection.open
IfObjConnection.State=adStateOpenThen
amount=1
Else
amount=0
EndIf
HMIRuntime.Tags("adress").writeamount
WithObjCommand
ActiveConnection=ObjConnection
CommandText="INSERTINTO表1(name.count)values(‘余厚祥’,25)"
EndWith
ObjConnand.Execute
判断连接成功与否程序好像跟本没有执行,更不用说插入数据了。我用的是ACCESS2013,ODBC配置好了,系统windows7,不知道有什么不对的地方

最佳答案

应该是你的ConnectionString有问题,建议你用odbc链接mdb数据库,然后wincc链接odbc。

提问者对于答案的评价:
试试看

  • 关注微信

猜你喜欢

微信公众号