# Adding DB pens to Easy chart issue

**URL:** <https://forum.inductiveautomation.com/t/adding-db-pens-to-easy-chart-issue/29879>\
**Category:** Ignition\
**Created:** [November 12, 2019, 3:03pm UTC](https://forum.inductiveautomation.com/t/adding-db-pens-to-easy-chart-issue/29879 "2019-11-12T15:03:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wschauer](https://avatars.discourse-cdn.com/v4/letter/w/ecccb3/32.png) [@wschauer](https://forum.inductiveautomation.com/u/wschauer)\
**Post date:** [November 12, 2019, 3:03pm UTC](https://forum.inductiveautomation.com/t/adding-db-pens-to-easy-chart-issue/29879/1 "2019-11-12T15:03:20Z")

</div>

Im using the AdHoc easy chart and dynamically adding pens to the dataset through a button script. The script adds the pens and i am able to see them in the table and in the easy chart configuration but i get the following SQL error. Also when i open the chart customizer and run the diagnostics on the new tag it has no errors and the tag added through the script appears the same as tags not added through the script. Not sure whats going on… Thanks in advance

“SQLQuery(query=SELECT t\_stamp, TCA1 FROM Tower\_C WHERE t\_stamp \>= ? AND t\_stamp \<= ? AND ORDER BY t\_stamp, database=MFG\_Controls)@0ms  
On: AdHoc Trend.AdHoc Trend.Easy Chart  
caused by GatewayException: Incorrect syntax near the keyword ‘ORDER’.  
caused by SQLServerException: Incorrect syntax near the keyword ‘ORDER’.”

Altering the Dataset script:

```
chart = event.source.parent.getComponent('Easy Chart').pens
newRow = [tag, tag, tbl, "t_stamp","MFG_Controls", "Default Axis", 1, 1, "0,0,255", 1, 1, 1, 0, 1, 0," "," ",0,0,0,1," ",0]
chart = system.dataset.addRow(chart, newRow)
event.source.parent.getComponent('Easy Chart').pens = chart

```

T

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 12, 2019, 3:06pm UTC](https://forum.inductiveautomation.com/t/adding-db-pens-to-easy-chart-issue/29879/2 "2019-11-12T15:06:24Z")

</div>

Looks like you are supplying a space for a where clause–it should be an empty string.

---

<div class="post-metadata">

**Author:** ![wschauer](https://avatars.discourse-cdn.com/v4/letter/w/ecccb3/32.png) [@wschauer](https://forum.inductiveautomation.com/u/wschauer)\
**Post date:** [November 12, 2019, 3:30pm UTC](https://forum.inductiveautomation.com/t/adding-db-pens-to-easy-chart-issue/29879/3 "2019-11-12T15:30:30Z")

</div>

Wow, thanks i should have caught that. Works perfect now.
