954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Textbox autocomplete in vb.net from sql server

Private Sub autocus()
Call main()
Con.Open()

Dim cmd As New SqlCommand("SELECT cust_order FROM Inventory", Con)

Dim ds As New DataSet
Dim da As New SqlDataAdapter(cmd)
da.Fill(ds, "My List") 'list can be any name u want

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)("cust_order").ToString())
Next
txt4.AutoCompleteSource = AutoCompleteSource.CustomSource
txt4.AutoCompleteCustomSource = col
txt4.AutoCompleteMode = AutoCompleteMode.Suggest
Con.Close()

End Sub

princenathan
Newbie Poster
8 posts since Oct 2010
Reputation Points: 8
Solved Threads: 2
 

Is this a sample of code that works or is it a piece of code that you are having a problem with?

If it is the first then you should explain what it does and how. If it is the second then you should explain what you are trying to do and what you are having a problem with.

Reverend Jim
Posting Shark
Moderator
1,167 posts since Aug 2010
Reputation Points: 253
Solved Threads: 159
 

Didn't intend to ding your rep. If you make another post here I'll offset it with a positive vote.

Reverend Jim
Posting Shark
Moderator
1,167 posts since Aug 2010
Reputation Points: 253
Solved Threads: 159
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: