Wondered if any one can help with the following problem. I am using a Vbscript within Siemens WinCC. When I activate the script and the "lngValue" variable contains a string with letters "BC" it displays an error when trying to insert into database.
If the "lngValue" was blank then a insert would be made into mysql database been blank all ok. (So connections all ok even tried with INT and worked)
I get following error:
[MySQL][ODBC 5.3(a) Driver][mysqld-5.6.19]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "BC' at line 1
The script is as follows:
Sub Writetomysql()
Dim lngValue
Dim lngValue1
Dim commandText
Dim objConn
Dim objRS
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "Driver={MySQL ODBC 5.3 ANSI Driver};Server=127.0.0.1;Database=siemens;UID=root;PWD=root;OPTION=3;"
Set objRS = CreateObject("ADODB.Recordset")
lngValue = SmartTags("ProductRunning_Mydata.ChargehandInitials")
lngValue1 = HMIRuntime.Tags("PPM").Read
commandText = "INSERT INTO products (ProductName, PPM) VALUES ('" _
& lngValue & "','" & lngValue1 & "')"
If SmartTags("FinishButton") = 1 Then
objRS.Open "products", objConn
objConn.Execute commandText
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
End If
End Sub
Thanks Steve.