title: Dynamic where clause in parameter
body: <p>I am currently trying to build up the where clause of an <code>SqlCommand</code>.</p>
  
  <p>something similar to this</p>
  
  <pre><code>myCommand.CommandText = "SELECT * " +
                          "FROM TABLE1 " + 
                          "@whereClause";
  //I build up the where clause with a StringBuilder
  myCommand.Parameters.AddWithValue("@whereClause" theClause.ToString());
  </code></pre>
  
  <p>But it doesn't seem like this is possible. I got the exception : </p>
  
  <blockquote>
    <p><em>SqlException Incorrect syntax near '@whereClause'</em></p>
  </blockquote>
  
  <p>The reason I want to do something like this is because I want to avoid X call to the database and this way I leave sorting and filtering to the server.</p>
  
  <p>Is there anyway to do something similar to this?</p>
  
  <p>/edit : The where clause would look something like this <code>WHERE (TABLE1.COL1 = 'the value' OR TABLE1.COL1 = 'another value' OR TABLE1.COL1 = 'this value' ... )</code></p>
  
  <p>/edit Finaly this was due to a stupid typo error... after I changed to not use the parametrize query. I'll upvote those answer who helped my out. I will mark as answer what was to closer to fix my situation even if it didn't fixed my (stupid) bug</p>