I have some textbox to send one word to sql database. i want to fine this word in a coulmn that holding few words. i cant figure it out what the correct queary iv'e try the LIKE statement in many ways but still nothing. The word can be at the first, middle or the end of the line. for example: the user write "sun" and in the DB table there is an addres: "Johnson Blvd 3647 sun corner, CA" because there is the word "sun" this record will show on.

the code is:

private void button3_Click(object sender, EventArgs e)
            SqlConnection sqlcon = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["forumArtDatabase"]);
            SqlCommand sqlcmd = new SqlCommand("SELECT * FROM orders WHERE billBoardNumber LIKE @p1", sqlcon);
            sqlcmd.Parameters.Add(new SqlParameter("@p1", SqlDbType.VarChar)).Value = billBoardNumber.Text;
            SqlDataAdapter da = new SqlDataAdapter(sqlcmd);
            dgByNumber.DataSource = ShowbillboardsByNumber;

Edited 7 Years Ago by John A: fixed code tags

You need to wrap the search terms in %'s -- that is the MSSQL wild care.

sqlcmd.Parameters.Add(new SqlParameter("@p1", SqlDbType.VarChar)).Value = "%" + billBoardNumber.Text + "%";
This question has already been answered. Start a new discussion instead.