title: How to pass in a SQL parameter when its too long
body: <p>I have a very big 'Where' statement that's longer then the maximum allowed.</p>
  
  <p>Currently I build the full sql in the vb.net code and I execute it. </p>
  
  <p>The problem is that this way is known to be slow because its not a compiled query.</p>
  
  <p>Is there any other way to do it?</p>
  
  <p>EDIT: </p>
  
  <pre><code>  For i As Integer = 0 To List.Count - 1
          If Filter = String.Empty Then
              Filter = " Where OrderID = "
          Else
              Filter += " OR OrderID ="
          End If
          Filter = Filter + "(" &amp; List(i) + ")"
      Next
  
      Sql = "Select * from OrderPickSheet " &amp; Filter &amp; " And Status &gt; -1 Order by SortOrder"
      cmd.CommandText = Sql
      cmd.ExecuteReader()
  </code></pre>