# Query binding, preview is returning null but works as named queries

**URL:** <https://forum.inductiveautomation.com/t/query-binding-preview-is-returning-null-but-works-as-named-queries/86228>\
**Category:** Ignition\
**Created:** [February 23, 2024, 3:29am UTC](https://forum.inductiveautomation.com/t/query-binding-preview-is-returning-null-but-works-as-named-queries/86228 "2024-02-23T03:29:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Breeding](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@Matthew\_Breeding](https://forum.inductiveautomation.com/u/Matthew_Breeding)\
**Post date:** [February 23, 2024, 3:29am UTC](https://forum.inductiveautomation.com/t/query-binding-preview-is-returning-null-but-works-as-named-queries/86228/1 "2024-02-23T03:29:37Z")

</div>

So I have a named query that works, but when I bind it as a query bind it returns null

named query:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/9/f9db0e7facfc4c00f1f10ed561d6bced563a26aa.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/c/6c65a13b579e48614e57fd594e042f358124daf8.png)

query binding:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/9/19b3b3d331c70fc796001cebcdc6f0408a3f1cf7.png)

I'm not sure why it does not work when it is referenced in binding but works in the name queries space

---

<div class="post-metadata">

**Author:** ![andrew.budaiev](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrew.budaiev/32/72921_2.png) [@andrew.budaiev](https://forum.inductiveautomation.com/u/andrew.budaiev)\
**Post date:** [February 23, 2024, 3:41am UTC](https://forum.inductiveautomation.com/t/query-binding-preview-is-returning-null-but-works-as-named-queries/86228/2 "2024-02-23T03:41:55Z")

</div>

Do you need a schema name there? Try without it

---

<div class="post-metadata">

**Author:** ![Matthew\_Breeding](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@Matthew\_Breeding](https://forum.inductiveautomation.com/u/Matthew_Breeding)\
**Post date:** [February 23, 2024, 3:49am UTC](https://forum.inductiveautomation.com/t/query-binding-preview-is-returning-null-but-works-as-named-queries/86228/3 "2024-02-23T03:49:57Z")

</div>

yes, that would do it, when I was inputting the URL I forgot to put  
'/databasename' so i need to reference it in my code but now that your brought this point up I made the correct adjustments and no longer need a schema and it functions.  
Thanks!

---

<div class="post-metadata">

**Author:** ![Giuseppe\_Giammo](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@Giuseppe\_Giammo](https://forum.inductiveautomation.com/u/Giuseppe_Giammo)\
**Post date:** [October 18, 2024, 9:56pm UTC](https://forum.inductiveautomation.com/t/query-binding-preview-is-returning-null-but-works-as-named-queries/86228/4 "2024-10-18T21:56:25Z")

</div>

Hi there, i am having the same issue and I cant get the binding to return ANYTHING... the named qry works fine with and without parameters ... any help is appreciated

![Screenshot 2024-10-18 175536](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/c/1c340a1340bd93d2b274d9c5b6430045f6418d18.jpeg)

 ![Screenshot 2024-10-18 175432](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/d/ed609a03b31075ea39d5258e442219548f6eb1c2.jpeg)

---

<div class="post-metadata">

**Author:** ![Matthew\_Breeding](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@Matthew\_Breeding](https://forum.inductiveautomation.com/u/Matthew_Breeding)\
**Post date:** [October 18, 2024, 10:32pm UTC](https://forum.inductiveautomation.com/t/query-binding-preview-is-returning-null-but-works-as-named-queries/86228/5 "2024-10-18T22:32:26Z")

</div>

For me when I was establishing the database connection in the gateway I did not apply a schema for it to connect too, try to make sure you followed the correct connection parameter and configuration. Show me pictures of that if possible

---

<div class="post-metadata">

**Author:** ![Giuseppe\_Giammo](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@Giuseppe\_Giammo](https://forum.inductiveautomation.com/u/Giuseppe_Giammo)\
**Post date:** [October 19, 2024, 3:12pm UTC](https://forum.inductiveautomation.com/t/query-binding-preview-is-returning-null-but-works-as-named-queries/86228/6 "2024-10-19T15:12:34Z")

</div>

SELECT dbo.tblmeterreads\_CB.DateTimeRead AS t\_stamp,  
dbo.tblmeterreads\_CB.kwh AS usage  
FROM dbo.tblmeterreads\_CB

this statement works in qry test but not returning anything when binding  
i tried both ways with the gateway set up and still no luck.

its a sql server 2022....

![Screenshot 2024-10-19 110812](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/0/3031e49053ffa6460ce156f37ddc6b3499841e26.jpeg)  
 ![Screenshot 2024-10-19 102747](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/0/f0d3c3e1d2c5d40a79496fed8982884420ce5401.jpeg)

it must be something so stupid that i am overlooking...  
is there a log that will show exactly what is used in binding?

---

<div class="post-metadata">

**Author:** ![Giuseppe\_Giammo](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@Giuseppe\_Giammo](https://forum.inductiveautomation.com/u/Giuseppe_Giammo)\
**Post date:** [October 21, 2024, 3:58pm UTC](https://forum.inductiveautomation.com/t/query-binding-preview-is-returning-null-but-works-as-named-queries/86228/7 "2024-10-21T15:58:53Z")

</div>

so as anticipated was something really stupid... you have to save the project every time a named query is created or updated ...!!!

---

<div class="post-metadata">

**Author:** ![Matthew\_Breeding](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@Matthew\_Breeding](https://forum.inductiveautomation.com/u/Matthew_Breeding)\
**Post date:** [October 24, 2024, 8:53pm UTC](https://forum.inductiveautomation.com/t/query-binding-preview-is-returning-null-but-works-as-named-queries/86228/8 "2024-10-24T20:53:54Z")

</div>

sorry took me so long to respond but yeah i pretty much had the same issue, its always something stupid lol. Congrats on finding it though!
