My Code is:
textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
AutoCompleteStringCollection col = new AutoCompleteStringCollection();
sqlconn.Open();
string query = "select id from cmp_det where id =" + textBox1.Text;
SqlCommand command = new SqlCommand(query, sqlconn);
SqlDataReader sdr = command.ExecuteReader();
while (sdr.Read())
{
col.Add(sdr["Column_Name"].ToString());
}
sdr.Close();
textBox1.AutoCompleteCustomSource = col;
sqlconn.Close();
Sometime it works correctly but sometime it gives error of "memory corrupt" in program.cs file when execute. also sometime it stops working with the error "Specified cast is not valid." Help me to solve these errors.
Girish SapariyaPosted Mar 14, 2014, 6:07 AM
string query = "select id from cmp_det where id =" + textBox1.Text;
as the "id" filed expects an integer, you have to cast the value of textBox1.Text as by default it is string
convert textBox1.Text to integer
like this:
string query = "select id from cmp_det where id =" + Convert.ToInt32(textBox1.Text);
hope this will help you
Angel PrincessPosted Mar 14, 2014, 5:42 AM
saurabh mittalPosted Mar 14, 2014, 4:31 AM
for windows forms u can refer to this link.may be it
will be helpful for u.
http://www.codeproject.com/Questions/339025/Autocomplete-textbox-in-windows-csharp
Angel PrincessPosted Mar 14, 2014, 4:07 AM
saurabh mittalPosted Mar 14, 2014, 3:48 AM
You can do it by jquery and ajax also.in this file both
method are given.check attachment file.
Angel PrincessPosted Mar 14, 2014, 3:09 AM
saurabh mittalPosted Mar 14, 2014, 2:56 AM
You can check this attachment project. like this u cn do it.