WinCC v6.0 VB script and SQL


Thread Starter


Using WinCC v6.0, I am trying to use the UPDATE statement to write data to an Access database. I keep getting syntax errors on the line. Here is what I have...

UPDATE TableName SET Field1 = 'Value' WHERE ID = '1'

Anybody have the correct syntax for this in VBScript??

All help is appreciated.


Hi Scott,

Your UPDATE statement syntax looks fine.

However this is an SQL command not a VBScript command. To use this in your VBS code you will have had to created an ADO connection and command object.

I'm assuming you have already done this and simply not mentioned it! If not, there is an example of how to connect and manipulate a database (it uses MSAccess but the fundamentals are the same for any other relational database) in the WinCC Manual under the VBS section.

If you post the full script and exact error message I can try and find the script fault.

hope this helps

Thank you for your reply. I got it resolved. It turned out to be a data type mismatch with what I was trying to SET. Being fairly new to ADO, SQL, etc. I was attempting to pass a string to a field expecting a number. Once I figured out the syntax for passing a WinCC tag in all was well.

My guess is you are the provider of very helpful examples on there.