Q:

i want code for Autocomplete Textbox Using Database Return Value in c#.net

private void txtBoxSearch_TextChanged(object sender, EventArgs e)
        {
        AutoCompleteStringCollection namecollection = new AutoCompleteStringCollection();

        SqlConnection con = new SqlConnection("connectionn string");
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandType = CommandType.Text;
        string searchFor = "%" + txtBoxSearch.Text + "%";
       com.CommandText = "select cust_nm from Customer_Info where  (cust_nm LIKE ' %  " + searchFor + " %') ";

        con.Open();
        cmd.Parameters.AddWithValue("@name", searchFor);
        SqlDataReader rea = cmd.ExecuteReader();
        if (rea.HasRows == true)
        {
            while (rea.Read())
                namecollection.Add(rea["name"].ToString());
        }
        rea.Close();

        txtBoxSearch.AutoCompleteMode = AutoCompleteMode.Suggest;
        txtBoxSearch.AutoCompleteSource = AutoCompleteSource.CustomSource;
        txtBoxSearch.AutoCompleteCustomSource = namecollection;

    }

i want textbox which is act as a search option

A:

A few problems here  

You set the CommandText on com but execute cmd  
You set % both on the variable and on the CommandText  
You add a parameter but you don't have the parameter in the CommandText

