Recent

Author Topic: how i can use ODBC SQL Query like with params  (Read 662 times)

eldonfsr

  • Hero Member
  • *****
  • Posts: 543
how i can use ODBC SQL Query like with params
« on: January 31, 2025, 04:17:08 pm »
Hi on paramas we can assign the field name witch we need find or select informatioon

is possible to use    select * from pn where  PnDetail like :%ItemDescription%
using params


   

paweld

  • Hero Member
  • *****
  • Posts: 1330
Re: how i can use ODBC SQL Query like with params
« Reply #1 on: January 31, 2025, 05:38:50 pm »
Code: Pascal  [Select][+][-]
  1. . SQLQuery1.SQL.Text := 'select * from pn where  PnDetail like :param1';
  2.   SQLQuery1.paramByName('param1').AsString := '%ItemDescription%';
Or
Code: Pascal  [Select][+][-]
  1. . SQLQuery1.SQL.Text := 'select * from pn where  PnDetail like ''%''+:param1+''%''';
  2.   SQLQuery1.paramByName('param1').AsString := 'ItemDescription';
Best regards / Pozdrawiam
paweld

eldonfsr

  • Hero Member
  • *****
  • Posts: 543
Re: how i can use ODBC SQL Query like with params
« Reply #2 on: January 31, 2025, 08:46:09 pm »
Ok Great Thanks...

Zvoni

  • Hero Member
  • *****
  • Posts: 2921
Re: how i can use ODBC SQL Query like with params
« Reply #3 on: February 10, 2025, 08:42:04 am »
This works on ONE single comparison.
If you want to compare with a Like against multiple criteria, it's a different kettle of fish
.. you know.... those blasted OR-constructs ".... WHERE PnDetail LIKE '%Crit1%' OR PnDetail LIKE '%Crit2%' OR ....."
There is an "elegant" way to boil that down
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018