creating DISTINCT values from a DataTable
First of all hello, this my first post here so be prepared for some bad grammer.
I'm working on an application right now that stores data in a dataset. The dataset works like a local cached copy of a portion of a larger SQL Server database. The data is downloaded into the application where the user works on it. The user then can upload the data back into the database whenever they are ready. All the data is stored and accessed locally.
On one of the applications forms I need a combo box that lists all the unique values of a datatable. I need to run a DISTINCT query on a datatable and bind the combo box to the results.
Me.ComboBox.DataSource = DataSet.DataTable.DefaultView.ToTable(True, New String() {"column"})
Me.ComboBox.DisplayMember = "column"
The DataView.ToTable() method returns a DataTable, True specifies that the DataTable will contain distinct values, while the string array contains the columns in the DataTable.