cm = new SqlCommand(); cm.Connection = cn; string searchFor = "%" + textBox1.Text + "%"; //the string the user entered. AutoCompleteStringCollection namecollection = new AutoCompleteStringCollection(); cm.CommandText = @"SELECT distinct itmname AS name FROM table1 WHERE name LIKE @name"; cm.Parameters.AddWithValue("@name", searchFor); SqlDataReader rea = cm.ExecuteReader(); if (rea.HasRows == true) { while (rea.Read()) namecollection.Add(rea["name"].ToString()); } rea.Close(); autoCompleteTextbox1.AutoCompleteCustomSource = namecollection;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)