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.
本文介绍了一种在本地数据集中实现 DISTINCT 查询的方法,通过使用 DataView.ToTable 方法返回包含唯一值的数据表,进而填充 ComboBox 控件。
844

被折叠的 条评论
为什么被折叠?



