Private Sub search()
Dim AutoComp As New AutoCompleteStringCollection()
sql = String.Format("select sup_name from tb_supplier where sup_name like '%{0}%'", TextBox1.Text)
cmd_excuteToDataTable()
For i As Integer = 0 To DS.Tables(0).Rows.Count - 1
AutoComp.Add(DS.Tables(0).Rows(i)(0).ToString())
Next
TextBox1.AutoCompleteMode = AutoCompleteMode.Suggest
TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
TextBox1.AutoCompleteCustomSource = AutoComp
End Sub
Tag : .NET, Ms SQL Server 2012, Win (Windows App), VB.NET, Windows
Dim conn As New SqlConnection("Data Source=***\SQLEXPRESS2;Initial Catalog=***;User ID=***;Password=***") 'basically connection string
Dim cmd As New SqlCommand("SELECT PART_NO FROM PRODUCT", conn)
Dim ds As New DataSet
Dim da As New SqlDataAdapter(cmd)
da.Fill(ds, "PART_NO")
Dim col As New AutoCompleteStringCollection
Dim i As Integer
For i = 0 To ds.Tables(0).Rows.Count - 1
col.Add(ds.Tables(0).Rows(i)("PART_NO").ToString())
Next
TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
TextBox1.AutoCompleteCustomSource = col
TextBox1.AutoCompleteMode = AutoCompleteMode.Suggest