I am trying to add a row into a SQL DB table. I have successfully used the following code in mySQL so I know that my SQL code should not have any syntax errors.
INSERT INTO sensor_notes (user, timestamp, sensor_number, notes)
VALUES ('name', 'currenttime', 'sensor_number', 'notes')
When I place it into ignition I know I have to change the VALUES so that they reflect defined variables within my scripting, and the following is my scripting code:
[code]user = “[System]Client/User/Username”
timestamp = “[System]Client/System/CurrentDateTime”
sensor_number = event.source.parent.sensorNumber
notes = event.source.parent.getComponent(‘Text Area’).text
insertQuery = “”“INSERT INTO sensor_notes (user, timestamp, sensor_number, notes)
VALUES (‘user’, ‘timestamp’, ‘sensor_number’, ‘notes’)”""
system.db.runPrepUpdate(insertQuery, [user, timestamp, sensor_number, notes], ‘db’)[/code]
I keep getting errors that this is not correct and I’m not sure what I am missing in my code. Any help would be appreciated so much! This is driving me crazy!