As usual, never use string concatenation to build sql command. Use parametrized queries
string query = "SELECT * FROM [Contact Management] WHERE Mobile=@mobile OR Name=@name";
SqlCommand cmd = new SqlCommand(query, con);
cmd.Parameters.AddWithValue("@mobile", Convert.ToInt32(txtSearch.Text));
cmd.Parameters.AddWithValue("@name", txtSearch.Text);
SqlDataAdapter da= new SqlDataAdapter (cmd);
The parametrized query will save your database from Sql Injection Attacks, but also from problems in parsing your input text. What if in the search text you have a single quote? You will get a syntax error with concatenation.
However, let me say that your code will fail before this. If you have a number in your txtSearch, then everything will work, but if you have a string. converting to a number with Convert.ToInt32 will fail. Better to use
SqlCommand cmd = new SqlCommand();
string query;
int numSearch;
if(Int32.TryParse(txtSearch.Text, out numSearch))
{
query = "SELECT * FROM [Contact Management] WHERE Mobile=@p1";
cmd.Parameters.AddWithValue("@p1", numSearch);
}
else
{
query = "SELECT * FROM [Contact Management] WHERE Name=@p1";
cmd.Parameters.AddWithValue("@p1", txtSearch.Text);
}
cmd.CommandText = query;
....
txtSearch.Textwrapped around any quotes what so ever.. I would personally look into usingParameterized Queryas well