Hi,
I am having a function which populates a combobox (cmbProjtype) as shown below,
I am trying to clear cmbProjtype before I populate again to remove duplicates whenever the function is called, but the line of code added (highlighted) is not doing it.. Any help pls
ThanksCode:Private Sub populatecmbprojtype() Dim cmd As New SqlCommand Dim conn As SqlConnection = GetDbConnection() cmbProjtype.SelectedIndex = -1 Try Dim Projtype As New System.Data.SqlClient.SqlCommand(("Select ProjectType From dbo.tblProjectTypes"), conn) Using reader As System.Data.SqlClient.SqlDataReader = Projtype.ExecuteReader() While reader.Read() Dim ProjectType As String = FixNull(reader.GetValue(0)) cmbProjtype.Items.Add(ProjectType) End While End Using Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Information, "VeriSIS") End Try End Sub




Reply With Quote