i want to make a textbox suggest all possible inputs based on a certain column in my database.

for example, i have a country column in the database and i want my textbox to display all countries from my database column that starts with P when i type it and so on. thanks :)

put a text box and button on a form

then use following code

Dim conn As New SqlConnection("Data Source=server;Initial Catalog=database;User ID=id; pwd=pass") 'basically connection string
        Dim cmd As New SqlCommand("SELECT columnname FROM table", conn)
        Dim ds As New DataSet
        Dim da As New SqlDataAdapter(cmd)
        da.Fill(ds, "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)("columnname").ToString())  //columnname same as in query

        Next




        TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
        TextBox1.AutoCompleteCustomSource = col
        TextBox1.AutoCompleteMode = AutoCompleteMode.Suggest
        TextBox1.AutoCompleteMode = AutoCompleteMode.Suggest
        TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
        Dim DataCollection As New AutoCompleteStringCollection()
        addItems(DataCollection)
        TextBox1.AutoCompleteCustomSource = DataCollection

Full Source : Autocomplete textbox from database

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.