# Add row to table in SQL Database

**URL:** <https://forum.inductiveautomation.com/t/add-row-to-table-in-sql-database/10395>\
**Category:** Ignition\
**Created:** [August 25, 2015, 8:42pm UTC](https://forum.inductiveautomation.com/t/add-row-to-table-in-sql-database/10395 "2015-08-25T20:42:57Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![OscarLucas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/oscarlucas/32/6417_2.png) [@OscarLucas](https://forum.inductiveautomation.com/u/OscarLucas)\
**Post date:** [February 3, 2021, 11:01am UTC](https://forum.inductiveautomation.com/t/add-row-to-table-in-sql-database/10395/21 "2021-02-03T11:01:52Z")

</div>

Hello All, i was reading all the post. And i arrive to one new error. I can't found the way to solve. Can you help me?  
My code  
value1 = event.source.parent.getComponent('Text Field').text  
value2 = event.source.parent.getComponent('Text Field 1').text  
value3 = event.source.parent.getComponent('Numeric Text Field user').intValue  
value4 = event.source.parent.getComponent('Numeric Text Field station').intValue

table = event.source.parent.getComponent('Power Table')

insertQuery = "INSERT INTO tasks (task\_name, task\_description, user\_id, station\_number) VALUES ('%s', '%s', %d, %d)"  
args = [value1, value2, value3, value4]

# Insert the record in the database table

system.db.runPrepUpdate(insertQuery, args, database='DB')

# Refresh the table data

system.db.refresh(table, "data")

My error

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/5/458bb7c58163a93c27807861eab7d197978aeb03.png)

---

<div class="post-metadata">

**Author:** ![Gaurav.Shitole](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/gaurav.shitole/32/72050_2.png) [@Gaurav.Shitole](https://forum.inductiveautomation.com/u/Gaurav.Shitole)\
**Post date:** [February 3, 2021, 11:28am UTC](https://forum.inductiveautomation.com/t/add-row-to-table-in-sql-database/10395/22 "2021-02-03T11:28:21Z")

</div>

> [@OscarLucas](#):
>
> insertQuery = “INSERT INTO tasks (task\_name, task\_description, user\_id, station\_number) VALUES (’%s’, ‘%s’, %d, %d)”

@OscarLucas Try it this way,

```auto
"INSERT INTO tasks (task_name, task_description, user_id, station_number) VALUES (?,?,?,?)”

```

---

<div class="post-metadata">

**Author:** ![OscarLucas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/oscarlucas/32/6417_2.png) [@OscarLucas](https://forum.inductiveautomation.com/u/OscarLucas)\
**Post date:** [February 4, 2021, 6:50am UTC](https://forum.inductiveautomation.com/t/add-row-to-table-in-sql-database/10395/23 "2021-02-04T06:50:56Z")

</div>

👍 done

[Previous page](https://forum.inductiveautomation.com/t/add-row-to-table-in-sql-database/10395.md?page=1)
