# Binding Errors on Evaluation Order

**URL:** <https://forum.inductiveautomation.com/t/binding-errors-on-evaluation-order/14678>\
**Category:** Ignition\
**Created:** [July 3, 2017, 7:53pm UTC](https://forum.inductiveautomation.com/t/binding-errors-on-evaluation-order/14678 "2017-07-03T19:53:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ErikG](https://avatars.discourse-cdn.com/v4/letter/e/91b2a8/32.png) [@ErikG](https://forum.inductiveautomation.com/u/ErikG)\
**Post date:** [July 3, 2017, 7:53pm UTC](https://forum.inductiveautomation.com/t/binding-errors-on-evaluation-order/14678/1 "2017-07-03T19:53:46Z")

</div>

When opening a window or template in the Designer, the SQL binding executes before the parameters have been evaluated, leaving errors similar to:  
caused by GatewayException: Connection Error: Datasource “-1” does not exist in this Gateway.  
caused by SQLException: Datasource “-1” does not exist in this Gateway.

It works fine in the Client. Any suggestions to cleanup this nuisance error?

---

<div class="post-metadata">

**Author:** ![cezipper](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@cezipper](https://forum.inductiveautomation.com/u/cezipper)\
**Post date:** [August 11, 2017, 4:29pm UTC](https://forum.inductiveautomation.com/t/binding-errors-on-evaluation-order/14678/2 "2017-08-11T16:29:45Z")

</div>

I have a similar problem that does effect the client. I am trying to get the primary key of the selected row of a table with:  
if({Root Container.Table.selectedRow} \>-1 ,  
{Root Container.Table.data}[{Root Container.Table.selectedRow},“task\_id”],  
-1)  
But I get a null pointer error because selected row has not updated yet and it is using the value I last saved the window with. No error if I saved the window with nothing selected (slectedRow = -1), but pointer errors if I saved the table with a row selected (selectedRow \>-1). I don’t want to have to save the table unslected every time I make an edit. Is there a way to make sure this binding does not execute until the table’s selected row has been evaluated?

---

<div class="post-metadata">

**Author:** ![ErikG](https://avatars.discourse-cdn.com/v4/letter/e/91b2a8/32.png) [@ErikG](https://forum.inductiveautomation.com/u/ErikG)\
**Post date:** [August 16, 2017, 12:46am UTC](https://forum.inductiveautomation.com/t/binding-errors-on-evaluation-order/14678/3 "2017-08-16T00:46:14Z")

</div>

I tried handling this with a script when then window opens, but what i found is my connections/tags just got evaluated twice.

Still no clean solution that I’ve come across

---

<div class="post-metadata">

**Author:** ![ray.crowder](https://avatars.discourse-cdn.com/v4/letter/r/e480ec/32.png) [@ray.crowder](https://forum.inductiveautomation.com/u/ray.crowder)\
**Post date:** [October 4, 2017, 6:02pm UTC](https://forum.inductiveautomation.com/t/binding-errors-on-evaluation-order/14678/4 "2017-10-04T18:02:41Z")

</div>

I am curious if you found a clean way to handle this situation.

---

<div class="post-metadata">

**Author:** ![ErikG](https://avatars.discourse-cdn.com/v4/letter/e/91b2a8/32.png) [@ErikG](https://forum.inductiveautomation.com/u/ErikG)\
**Post date:** [October 4, 2017, 7:30pm UTC](https://forum.inductiveautomation.com/t/binding-errors-on-evaluation-order/14678/5 "2017-10-04T19:30:34Z")

</div>

Unfortunately, no. We still get a lot of errors - but only in the Designer

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [October 9, 2017, 11:33am UTC](https://forum.inductiveautomation.com/t/binding-errors-on-evaluation-order/14678/6 "2017-10-09T11:33:25Z")

</div>

Wrap the expression in a try() ?

---

<div class="post-metadata">

**Author:** ![j.abrante](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/j.abrante/32/10431_2.png) [@j.abrante](https://forum.inductiveautomation.com/u/j.abrante)\
**Post date:** [August 14, 2019, 7:56am UTC](https://forum.inductiveautomation.com/t/binding-errors-on-evaluation-order/14678/7 "2019-08-14T07:56:16Z")

</div>

Sometimes this also happens to me in the designer when I try to make a simple query where I pass parameters. To solve it first I do the format of the string of the query and then I pass the string to the runquery method.

```auto
query = "SELECT * FROM report_configuration WHERE id=%s" % (i)
reports = system.db.runQuery(query)

```
