キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Populate a text ring from SQL query. How?

解決済み
解決策を見る

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 件の賞賛
メッセージ1/11
1,778件の閲覧回数

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

0 件の賞賛
メッセージ2/11
1,772件の閲覧回数

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

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 件の賞賛
メッセージ3/11
1,764件の閲覧回数

@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 件の賞賛
メッセージ4/11
1,750件の閲覧回数

@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 件の賞賛
メッセージ5/11
1,749件の閲覧回数

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 件の賞賛
メッセージ6/11
1,732件の閲覧回数

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

 

snip.png

0 件の賞賛
メッセージ7/11
1,727件の閲覧回数

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

Seli6272@D
0 件の賞賛
メッセージ8/11
1,718件の閲覧回数

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 件の賞賛
メッセージ9/11
1,716件の閲覧回数
解決策
トピック作成者LZD_Sydneyが受理

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

 

Try: SELECT Name, ID FROM Unitclass

0 件の賞賛
メッセージ10/11
1,716件の閲覧回数