c# combobox fill from database

2017/10/05 03:18
To get only the unique /distinct/ data table records from any database connected to DataSet in C# project and to put them inside combobox.
Fill the table adapter with the records from database.
Create a view containing the database table
DataView view = new DataView(this.myDB_DataSet.myDBTable);
Copy only the distinct records to new data table.
DataTable distinctValues = view.ToTable(true, "column_name");
For the combobox created, set the data source and display member properties.
private System.Windows.Forms.ComboBox my_ComboBox;
my_ComboBox.DataSource = distinctValues ;
my_ComboBox.DisplayMember = "column_name";