LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read data from a database and display it in a listbox

Solved!
Go to solution

hi ,

i want read data from a table in a database then i want display 1 column  in a listbox.

i read data from database but i can;t display it in a listbox.

anyone can help me plz?

0 Kudos
Message 1 of 7
(5,397 Views)

Post the vi in 2009 or older format or the snippet of the code.

 

 

-Nilesh



------------------------------------------------------------------------------------------------------
Kudos are (always) welcome for the good post. 🙂
0 Kudos
Message 2 of 7
(5,394 Views)
0 Kudos
Message 3 of 7
(5,391 Views)

You don't have a Listbox on the front panel. To populate a Listbox you need to write to the Listbox's ItemName property and write a 1D array of strings. To get your 1D array of strings you need to use the Database Variant to Data function to conver the variant you get from the database functions. Please review the examples that are installed with the Database Toolkit.

 

Notes on code:

  • The sequence structure is not necessary. Dataflow will control the executtion flow in this case.
  • You should not hard-code paths and connection strings in your code. What if you want to run the code on another computer? What if you need to connect to another database?

I would also suggest that you review basic LabVIEW programming principles. To learn more about LabVIEW it is recommended that you go through the introduction material, tutorial(s), and other material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. There are also several Technical Resources. You can also take the online courses for free.

0 Kudos
Message 4 of 7
(5,378 Views)

ok thanks,it's helpfull

i change my code and there is some data displayed  in the listbox.i want to display in the listbox the second column in the table that i attached its view as png file

but only the first value of the column is displayed

how i can display the other values?

Download All
0 Kudos
Message 5 of 7
(5,366 Views)
Solution
Accepted by topic author iman

Your VI is way overcomplicated. If you're getting a 2D array and you just want the second column you only need to use Index Array to peel off the second column. That's it.

 

Again, your sequence structure is completely unnecessary.

 

 

 

I will reiterate my statement about spending some time with the LabVIEW tutorials.

0 Kudos
Message 6 of 7
(5,335 Views)

thanks 🙂 all is ok

0 Kudos
Message 7 of 7
(5,303 Views)