0

I have following code;

  Dm.QrTmp.SQL.Add('(Select sum (sth.sth_tutar+sth.sth_vergi) from    
  '+MikActiveDb+'STOK_HAREKETLERI sth ');
  Dm.QrTmp.SQL.Add('where (sth.sth_tarih>= :ptar1 and sth.sth_tarih<= :ptar2)  ');

I have set parameters like this.

  Dm.QrTmp.Parameters.ParamByName('ptar1').DataType := ftDate;
  Dm.QrTmp.Parameters.ParamByName('ptar2').DataType := ftDate;
  Dm.QrTmp.Parameters.ParamByName('ptar1').Value := Tarih1.Value;
  Dm.QrTmp.Parameters.ParamByName('ptar2').Value := Tarih2.Value;

But in run time delphi give me an error ;

Parameter object is improperly defined. Inconsistent or incomplete information was provided.
ikutluay
  • 142
  • 9
  • Tarih1 and Tarih2 are component and they can have date/time/datetime type values. In this code they have date values. – ikutluay Feb 20 '15 at 16:20
  • 2
    Assuming that you are using ADO based dataset component and your field is of type [`date`](https://msdn.microsoft.com/en-us/library/bb630352.aspx) (both should have been mentioned, along with a Delphi version tag, in your question), follow e.g. [`this post`](http://stackoverflow.com/a/19855691/960757). – TLama Feb 20 '15 at 16:34
  • Yes. It is a adoquery, fields are date dtype field and im using xe7 – ikutluay Feb 21 '15 at 07:00
  • According the link you proposed i have changed code and it worked. But it doesnt worked when i used ptar1 and ptar2 in second sentence. So i have tried with second sentence for ptar3 and ptar4 then it has worked. Now the question is can we use a defined parameter in sql twice or not? – ikutluay Feb 21 '15 at 07:15
  • 1
    no you can't use a parameter twice, just define a new one and set the same value. – whosrdaddy Feb 22 '15 at 10:48

0 Answers0