Is this the perfect code to retrieve data from table to combobox?
-
Is the following code correct to load table field data to ComboBox? It is working fine but would like to know whether it is the perfect one.
Public Function cboLoadPlants()
Dim dt As DataTable = DAL.LoadData("SELECT DISTINCT Trim(Company) As [Company] FROM CompaniesTable").Tables(0)
cboCompany.ValueMember = "Company"
cboCompany.DataSource = dt
cboCompany.SelectedIndex = 0
Return True
txtSearch.Select()
End Function -
Is the following code correct to load table field data to ComboBox? It is working fine but would like to know whether it is the perfect one.
Public Function cboLoadPlants()
Dim dt As DataTable = DAL.LoadData("SELECT DISTINCT Trim(Company) As [Company] FROM CompaniesTable").Tables(0)
cboCompany.ValueMember = "Company"
cboCompany.DataSource = dt
cboCompany.SelectedIndex = 0
Return True
txtSearch.Select()
End Function -
Please use the correct foruim[^]; this is not a Visual Studio issue.
Thanks. I will check it there.