Nahid Hasan

Nahid Hasan

  • NA
  • 16
  • 957

How do I AutoComplete images like this?

May 4 2023 3:24 PM

Here is my code but its work only first word..

dbcon.Open();
try
{
    AutoCompleteStringCollection pAuto = new AutoCompleteStringCollection();
    string query = "SELECT DISTINCT FullDescription FROM ProductInfo WHERE FullDescription LIKE '%'+@pattern+'%'";
    SqlCommand cmd = new SqlCommand(query, dbcon);
    cmd.Parameters.AddWithValue("@pattern", '%'+txtProductGroup.Text+'%');
   // dbcon.Open();
    SqlDataReader Contains = cmd.ExecuteReader();
    AutoCompleteStringCollection autoCompleteList = new AutoCompleteStringCollection();
    while (Contains.Read())
    {
        autoCompleteList.Add(Contains["FullDescription"].ToString());
    }
    txtProductGroup.AutoCompleteCustomSource = autoCompleteList;
    Contains.Close();
   // dbcon.Close();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}
dbcon.Close();

 


Answers (1)