In this post we learn about combo boxe and how we can avoid duplicate entries. For this we have to take a combo box from Toolbox. Then following the video instruction is to use the below coding. This is especially needed in many database management software..
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.IO
Public Class Form1
Dim cnoo As New SqlConnection("")
Dim dr As SqlDataAdapter
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim comded As New SqlCommand("Select Distinct Name From Table1 Order by Name", cnoo)
Dim adapter As New SqlDataAdapter(comded)
Dim tabled As New DataTable()
adapter.Fill(tabled)
Dim row As DataRow = tabled.NewRow()
row(0) = ""
tabled.Rows.InsertAt(row, 0)
ComboBox1.DataSource = tabled
ComboBox1.DisplayMember = "Name"
ComboBox1.ValueMember = "Name"
End Sub
End Class