# Error With ASCII Control Character In Data Field

**URL:** <https://forum.inductiveautomation.com/t/error-with-ascii-control-character-in-data-field/6395>\
**Category:** Ignition\
**Created:** [May 7, 2013, 2:46pm UTC](https://forum.inductiveautomation.com/t/error-with-ascii-control-character-in-data-field/6395 "2013-05-07T14:46:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamesPresley](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@JamesPresley](https://forum.inductiveautomation.com/u/JamesPresley)\
**Post date:** [May 7, 2013, 2:46pm UTC](https://forum.inductiveautomation.com/t/error-with-ascii-control-character-in-data-field/6395/1 "2013-05-07T14:46:17Z")

</div>

I’m having an issue with an ASCII string that has a control character in it. Specifically the “Group Separator” (Decimal 29, Hex 1d)

We are updating a table with a SQL query. The customer has serial numbers with the Group Separator in them. When we execute the query using the serial numbers in the where clause we get the attached error message.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/fd6e0b980c0aeab99bc5ab5da54fd8ccf355f30c.JPG)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 7, 2013, 3:26pm UTC](https://forum.inductiveautomation.com/t/error-with-ascii-control-character-in-data-field/6395/2 "2013-05-07T15:26:23Z")

</div>

Can you replace the group separator with a space wherever you’re getting these serial numbers from?

---

<div class="post-metadata">

**Author:** ![JamesPresley](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@JamesPresley](https://forum.inductiveautomation.com/u/JamesPresley)\
**Post date:** [May 7, 2013, 6:51pm UTC](https://forum.inductiveautomation.com/t/error-with-ascii-control-character-in-data-field/6395/3 "2013-05-07T18:51:23Z")

</div>

The serial number is laser etched into a 2D code permanently on the finished product. So it must be preserved in this format in the database for a future lookups. MS SQL seems to have no trouble with it. Also the SQL bridge module has no problems with storing the serial number to a database or recalling it from one.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 7, 2013, 7:03pm UTC](https://forum.inductiveautomation.com/t/error-with-ascii-control-character-in-data-field/6395/4 "2013-05-07T19:03:38Z")

</div>

Yeah, the problem is that the query ends up getting sent to the gateway inside an XML CDATA block and the XML spec doesn’t allow most of the ascii character codes \<= 0x20.

We should be able to get this fixed somehow for 7.5.9 though…

---

<div class="post-metadata">

**Author:** ![JamesPresley](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@JamesPresley](https://forum.inductiveautomation.com/u/JamesPresley)\
**Post date:** [May 7, 2013, 7:31pm UTC](https://forum.inductiveautomation.com/t/error-with-ascii-control-character-in-data-field/6395/5 "2013-05-07T19:31:52Z")

</div>

+1 waiting patiently for that upgrade.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 21, 2013, 11:41pm UTC](https://forum.inductiveautomation.com/t/error-with-ascii-control-character-in-data-field/6395/6 "2013-05-21T23:41:04Z")

</div>

Ok, so I’ve changed it so that system.db.runPrepUpdate and system.db.runPrepQuery can accept any unicode characters in strings in their argument lists. Actually, system.db.runPrepQuery already could, so all I changed is system.db.runPrepUpdate. This is what you’re using, right? It wasn’t clear from your posts.

Edit - not sure what you’re doing now that I look over your posts. You certainly won’t be able to include this string into a normal query. You’ve got to use the prepared versions.

---

<div class="post-metadata">

**Author:** ![JamesPresley](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@JamesPresley](https://forum.inductiveautomation.com/u/JamesPresley)\
**Post date:** [May 23, 2013, 7:52pm UTC](https://forum.inductiveautomation.com/t/error-with-ascii-control-character-in-data-field/6395/7 "2013-05-23T19:52:34Z")

</div>

We are doing a SQL Query with Unicast characters in the ASCII string of the where clause.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 23, 2013, 9:02pm UTC](https://forum.inductiveautomation.com/t/error-with-ascii-control-character-in-data-field/6395/8 "2013-05-23T21:02:50Z")

</div>

You cannot insert ASCII control characters directly into a normal query. You’ll have to use the runPrepQuery and runPrepUpdate versions, where the query arguments get passed in as objects
