title: Delphi7 SQL Server 2008 - The data types varchar and text are incompatible in the greater than or equal to operator
body: <p>Please assist,</p>
  
  <p>I have been getting this error whenever I pass values to a parameter using code similar to:</p>
  
  <pre><code>parameters.paramByName('ParamVal1').value := trim(TextBox1.Text);
  parameters.paramByName('ParamVal2').value := trim(TextBox2.Text);
  </code></pre>
  
  <p>So, if one of the text boxes is blank, then the error:</p>
  
  <blockquote>
    <p>The data types varchar and text are incompatible in the greater than or equal to operator</p>
  </blockquote>
  
  <p>appears.</p>
  
  <p>What could be wrong? </p>
  
  <hr>
  
  <p>After Running the sqlprofiler as suggested below</p>
  
  <pre><code>exec sp_executesql N'Select * from BLOtherChargeDetails 
  
  where Field1 = @P1 and Field2 &gt;= @P2 and Field2 &lt;= @P3 and
  Field3 &gt;= @P4 and Field3 &lt;= @P5 and
  Field4 &gt;= @P6 and Field4 &lt;= @P7 and 
  Field5 = @P8
  
  Order By Field2, Field3
  ',N'@P1 varchar(50),@P2 text,@P3 varchar(5),@P4 text,@P5 varchar(5),@P6 varchar(8),@P7 varchar(8),@P8 smallint','Value_P1','','ZZZZZ','','ZZZZZ','20130401','20130611',0
  go
  </code></pre>