# Error updating DB from runUpdateQuery

**URL:** <https://forum.inductiveautomation.com/t/error-updating-db-from-runupdatequery/5426>\
**Category:** Ignition\
**Created:** [November 15, 2012, 3:48am UTC](https://forum.inductiveautomation.com/t/error-updating-db-from-runupdatequery/5426 "2012-11-15T03:48:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![0sm0](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/0sm0/32/15228_2.png) [@0sm0](https://forum.inductiveautomation.com/u/0sm0)\
**Post date:** [November 15, 2012, 3:48am UTC](https://forum.inductiveautomation.com/t/error-updating-db-from-runupdatequery/5426/1 "2012-11-15T03:48:16Z")

</div>

Hi Guys,

I have the below action script on a button that takes the updated text in a text area and updates the DB table. It works fine most of the time but when some specific characters are used it errors.

[code]ID = event.source.parent.getComponent(‘Table’).SelectedID  
Note = event.source.parent.getComponent(‘Text Area’).text  
DB = system.tag.read("[]Plant Info\Project Name")

system.db.runUpdateQuery(“UPDATE notes SET NoteText = ‘%s’ WHERE ID = %s” % (Note,ID), DB.value)  
system.gui.messageBox(“Update Completed”)[/code]

I have read that using the runPrepUpdate would possibly solve the issue but cant get my head around making the PrepUpdate work??

Using MS SQL

Any help would be fantastic…

Cheers

Tim…

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [November 15, 2012, 4:35pm UTC](https://forum.inductiveautomation.com/t/error-updating-db-from-runupdatequery/5426/2 "2012-11-15T16:35:10Z")

</div>

You should use the runPrepUpdate funcition:[code]ID = event.source.parent.getComponent(‘Table’).SelectedID  
Note = event.source.parent.getComponent(‘Text Area’).text  
DB = system.tag.read("[]Plant Info\Project Name")

system.db.runPrepUpdate(“UPDATE notes SET NoteText = ? WHERE ID = ?”, [Note,ID], DB.value)  
system.gui.messageBox(“Update Completed”)[/code]

---

<div class="post-metadata">

**Author:** ![0sm0](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/0sm0/32/15228_2.png) [@0sm0](https://forum.inductiveautomation.com/u/0sm0)\
**Post date:** [November 15, 2012, 9:59pm UTC](https://forum.inductiveautomation.com/t/error-updating-db-from-runupdatequery/5426/3 "2012-11-15T21:59:50Z")

</div>

Haha, Thanks Travis,

I had tried various interations that just didn’t work.

But I now see the error of my ways…

cheers for the help.
