conn.Open();
//comm = new SqlCommand("SELECT DISTINCT nom_complet FROM church", conn);
comm = new SqlCommand("SELECT name FROM church where mobile like('" + "txtMobileNumber.Text" + "%')");
SqlDataReader sdr = comm.ExecuteReader();//Its point here as error
DataTable dt = new DataTable();
dt.Load(sdr);
cbxReadNomFlashMessage.DisplayMember = "name";
cbxReadNomFlashMessage.DroppedDown = true;
List<string> list = new List<string>();
foreach (DataRow row in dt.Rows)
{
list.Add(row.Field<string>("name"));
}
this.cbxReadNomFlashMessage.Items.AddRange(list.ToArray<string>());
cbxReadNomFlashMessage.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
cbxReadNomFlashMessage.AutoCompleteSource = AutoCompleteSource.ListItems;
conn.Close();
///////////////////////doesnt allow repeat item in combobox////////////
for (int i = 0; i < cbxReadNomFlashMessage.Items.Count; i++)
{
for (int y = 0; y < cbxReadNomFlashMessage.Items.Count; y++)
{
if (y != i && cbxReadNomFlashMessage.Items[i].ToString() == cbxReadNomFlashMessage.Items[y].ToString())
{
cbxReadNomFlashMessage.Items.RemoveAt(i);
break;
}
}
}