Insert row into MySQL Table

I have a maintenance screen/page where the sole purpose is to insert, update, delete rows from a MySQL table. The MySQL tables are already created and some have data that I imported.

I can’t seem to insert a copy of the screen/page I created but it has 2 fields. A text field and a drop down. And there’s a “Add” button.

In_Location_Name = event.source.parent.getComponent(‘txtNewLocation’).text
In_Location_Type = event.source.parent.getComponent(‘ddLocationType’).selectedValue
In_Table = event.source.parent.getComponent(‘locations’)

Insert_Query = “Insert Into locations (Location_Name, Location_Type) Values (’?’,’?’)”

args = [In_Location_name, In_Location_Type]

system.db.runPrepUpdate(Insert_Query, args, database = ‘MySQL’)


  1. Is this the correct format to use to insert a row of data into a MySQL table using the mouse click event?

  2. When I run it, I don’t get any errors. Perhaps there is something I need to set up to capture errors.

My apologies upfront. I was an Oracle programmer and used VB. Ignition is totally new to me.

Thanks in advance.

You’re actually pretty close - I suspect that the only issue is in your query.
When you use ? for parameterized substitution, you should not surround them in quotes; use literal ? in the query string:
Insert_Query = "INSERT INTO locations (Location_Name, Location_Type) VALUES (?, ?)"
If you use quotes, then you’re constructing a query that will (attempt to) insert literal question marks into the target table, which will probably fail.