# Named Query by Drop Down List for Month in the Vision Module

**URL:** <https://forum.inductiveautomation.com/t/named-query-by-drop-down-list-for-month-in-the-vision-module/79086>\
**Category:** Ignition\
**Tags:** vision, ignition81, database\
**Created:** [September 13, 2023, 2:59pm UTC](https://forum.inductiveautomation.com/t/named-query-by-drop-down-list-for-month-in-the-vision-module/79086 "2023-09-13T14:59:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Soltwedel](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Andrew\_Soltwedel](https://forum.inductiveautomation.com/u/Andrew_Soltwedel)\
**Post date:** [September 13, 2023, 2:59pm UTC](https://forum.inductiveautomation.com/t/named-query-by-drop-down-list-for-month-in-the-vision-module/79086/1 "2023-09-13T14:59:23Z")

</div>

Hey Guys,

I'm having a problem with pulling the Value from the drop down list and populating that value into my Named Query. I'm not sure what I'm doing wrong.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/c/acb47b3ae97ea6ade1c04b03cb5ffc434c91542f.png)  
My Selected value for September is an Integer of 9, but when my Query tries to run it faults out saying:  
Conversion error: query returned "Date", binding needs "Integer" on query binding for "Table Testing.Root Container.Dropdown.selectedValue"

I'm not sure why since what I'm pointing to is an integer. I'm sure it's something simple I am doing wrong.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/2/32fe29097031c7048c6ccc88113737fc38623cc3.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 13, 2023, 3:12pm UTC](https://forum.inductiveautomation.com/t/named-query-by-drop-down-list-for-month-in-the-vision-module/79086/2 "2023-09-13T15:12:55Z")

</div>

Is the binding in your screenshot the binding that's visible on `selectedValue`?

Explain what you're trying to do in more detail, because currently there's a binding trying to **set** the month value from the query result.

---

<div class="post-metadata">

**Author:** ![Kfoldesi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kfoldesi/32/11327_2.png) [@Kfoldesi](https://forum.inductiveautomation.com/u/Kfoldesi)\
**Post date:** [September 13, 2023, 3:13pm UTC](https://forum.inductiveautomation.com/t/named-query-by-drop-down-list-for-month-in-the-vision-module/79086/3 "2023-09-13T15:13:03Z")

</div>

What is the Select statement. Maybe it is talking about what SQL returned?

---

<div class="post-metadata">

**Author:** ![Andrew\_Soltwedel](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Andrew\_Soltwedel](https://forum.inductiveautomation.com/u/Andrew_Soltwedel)\
**Post date:** [September 13, 2023, 3:20pm UTC](https://forum.inductiveautomation.com/t/named-query-by-drop-down-list-for-month-in-the-vision-module/79086/4 "2023-09-13T15:20:28Z")

</div>

@paul-griffith Yes, sorry I should've made that clear. The drop down list has September selected which is a value of 9. Making the Selected Value 9. This is set-up as an integer, which is what my database wants.

Here's my SQL Query code where I'm trying to select my time frame. Which works when I do a Testing Query.

```auto
WHERE MONTH(Time_Stamp) = :Month AND YEAR(Time_Stamp) = :Yeartype or paste code here

```

---

<div class="post-metadata">

**Author:** ![Kfoldesi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kfoldesi/32/11327_2.png) [@Kfoldesi](https://forum.inductiveautomation.com/u/Kfoldesi)\
**Post date:** [September 13, 2023, 3:23pm UTC](https://forum.inductiveautomation.com/t/named-query-by-drop-down-list-for-month-in-the-vision-module/79086/5 "2023-09-13T15:23:51Z")

</div>

maybe Yeartype is returning a Date not Int?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 13, 2023, 3:24pm UTC](https://forum.inductiveautomation.com/t/named-query-by-drop-down-list-for-month-in-the-vision-module/79086/6 "2023-09-13T15:24:14Z")

</div>

We're talking past each other, I think.

From the two screenshots you originally posted, you've got a binding on `yourDropdown.selectedValue`. A binding is used to **provide** a value - so _if the binding on that property_ is in fact the named query binding you're showing in your other screenshot, what's happening is that as soon as you open the window, the query is being run (with whatever selected value was last saved in the designer being fed into the query) and then the query is running and trying to mash the first row/first column's result into the `selectedValue` property of your dropdown.

That is **almost certainly** not what you want. If you want to trigger a named query _when the dropdown's selected month changes_, which is what you actually _do_ want, I suspect, you need to use a **script** , not a binding.

---

<div class="post-metadata">

**Author:** ![Andrew\_Soltwedel](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Andrew\_Soltwedel](https://forum.inductiveautomation.com/u/Andrew_Soltwedel)\
**Post date:** [September 13, 2023, 4:30pm UTC](https://forum.inductiveautomation.com/t/named-query-by-drop-down-list-for-month-in-the-vision-module/79086/7 "2023-09-13T16:30:46Z")

</div>

What I wanted to do was select the month, and year of the data, insert that information into the Query. Then have a separate button to actually trigger the query with the inserted date/year.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/1/81ee707af289ff17428afab088c0cf1037e24250.png)

That way the Query would only trigger when the button was pressed. Is this feasible with a Named Query or only via Scripting.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 23, 2023, 2:16am UTC](https://forum.inductiveautomation.com/t/named-query-by-drop-down-list-for-month-in-the-vision-module/79086/8 "2023-09-23T02:16:21Z")

</div>

> [@Andrew\_Soltwedel](#):
>
> Is this feasible with a Named Query or only via Scripting.

Using a named query is correct, but to do it in the way you are describing, the named query will need to be called from the actionPerfomed event handler of your button. Just pass the selected values from the dropdowns into the parameter dictionary that gets passed into the named query when it is called:  
[https://docs.inductiveautomation.com/display/DOC81/system.db.runNamedQuery](https://docs.inductiveautomation.com/display/DOC81/system.db.runNamedQuery)
