LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Populate a text ring from SQL query. How?

Solved!
Go to solution

I am using a SQL query to populate a Text ring. I need both IDs in the digital disply, and the item names in the text field of the Ring. So far I have always used my functions and SQL query to populate the data in a multicolumn list box, but I don't know how to do it in a ring. The reason behind this choice is to give the user the oppotunity to use a dropdown menu to choose one of the items, or if they know the item ID, type the ID in the ditial disply, and the corresponding item would show up for further functions. Can someone help me please? 

I have simplified my code in the screenshot below, but can't post the VI since it is sending query to my database. There is also a screenshot of the variant to multicolumn list box subVI that I am using. 

 

Seli6272@D
0 Kudos
Message 1 of 11
(397 Views)

Create a 'StringsAndValues[]' property node for the ring control. The data type is an 1D array of cluster of 'string' and 'value' pairs.

0 Kudos
Message 2 of 11
(391 Views)

Only a further minor note: the sequence structure in the subvi is useless.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 11
(383 Views)

@pincpanter wrote:

Only a further minor note: the sequence structure in the subvi is useless.


It's not just the sequence structure, this basically does the same.

 

RamonG_1-1721980711083.png

 

 

0 Kudos
Message 4 of 11
(369 Views)

@UliB my problem is, I don't know how to use the output of my SQL query, which is recordset data, to populate it. At the moment, as I mentioned, I get a multicolumn listbox reference, but that is obviously not compatible with a ring property node of strings and values. 

 

p.s. I know my current structure is useless and may not make much sense, but I have only created a simplified version of my complicated code for the sake of my question. Thanks in advance for all the useful tips.

Seli6272@D
0 Kudos
Message 5 of 11
(368 Views)

Hi Seli,

 


@LZD_Sydney wrote:
my problem is, I don't know how to use the output of my SQL query, which is recordset data, to populate it. At the moment, as I mentioned, I get a multicolumn listbox reference, but that is obviously not compatible with a ring property node of strings and values. 

Your MCLB gets a 2D array of items, a ring needs a 1D array of strings:

  • get the required strings from the 2D array (by using IndexArray)
  • then build an array of clusters of (string, value) from your 1D array of strings (using a loop and Bundle)
  • set the String&Values property of your ring control...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 11
(351 Views)

Set up your query to output strings and values and feed the same data type to Database Variant to Data

 

snip.png

0 Kudos
Message 7 of 11
(346 Views)

@RamonG I just did, and it gives me Error 1129! I also tried with DISTINCT. 

Seli6272@D
0 Kudos
Message 8 of 11
(337 Views)

Hi @GerdW.

 

Thanks for the step by step guidance. There is only 1 problem: The IDs are not necessarily sequentially all the numbers, there maybe one or two missing (example 1, 2, 3, 5, 7, 8, 9...). Therefore, I can't just use auto indexing, but I actually need to get column 1 as index and column 2 as text/item name. 

Seli6272@D
0 Kudos
Message 9 of 11
(335 Views)
Solution
Accepted by topic author LZD_Sydney

The order inside your query must be the same as in the cluster constant.

 

Try: SELECT Name, ID FROM Unitclass

0 Kudos
Message 10 of 11
(335 Views)