title: Trying to solve embedded SQL code syntax error
body: <p>I have a fairly simple web app that is used to let people interact with a local database. The embedded SQL is throwing the following error:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException: 'Incorrect syntax near '&lt;'.'</p>
  </blockquote>
  
  <p>This only happens when the text box is empty. If it contains data everything works as it should. I would like for the query to essentially ignore the field if it is blank.</p>
  
  <pre><code>protected void findBTN_Click(object sender, EventArgs e)
  {
      using (SqlConnection sqlCon = new SqlConnection(connString))
      {
          sqlCon.Open();
          string query = "SELECT * FROM[OEM_Ref] WHERE DrawID like CASE WHEN " + drawerIDbox.Text + " &lt;&gt; '' THEN '" + drawerIDbox.Text + "%' ELSE '%' End";
  
          SqlDataAdapter sqlDa = new SqlDataAdapter(query , sqlCon);
          DataTable dtbl = new DataTable();
          sqlDa.Fill(dtbl);
  
          GridView1.DataSource = dtbl;
          GridView1.DataBind();
      }
  }
  </code></pre>