Recent

Author Topic: assigning select to sqlquery.sql.text  (Read 7139 times)

yordan

  • New Member
  • *
  • Posts: 18
assigning select to sqlquery.sql.text
« on: December 20, 2010, 12:21:36 pm »
 What I'm trying to do is assign the sql command  
 select * from table_name where some_column like '%a%'  
 I have troubles to insert the '% character into the following command
 sqlquery1.sql.text:='select * from grupist where name like'+ quotedstr(edit4.text)
 When I try typing the following
 sqlquery1.sql.text:='select * from grupist where name like'%'+ quotedstr(edit4.text) + '%''
 it doesn't work properly(the compiler accepts the +quotedstr(edit4.text) part as a string and the % as an operator).  
 Can someone help  ::)  

clauslack

  • Sr. Member
  • ****
  • Posts: 275
Re: assigning select to sqlquery.sql.text
« Reply #1 on: December 20, 2010, 01:03:49 pm »
Try this

sqlquery1.sql.text:='select * from grupist where name like'+
QuotedStr('%'+edit4.text+'%');

or

sqlquery1.sql.text:='select * from grupist where name like'+
QuotedStr('%'+Trim(edit4.text)+'%');

yordan

  • New Member
  • *
  • Posts: 18
Re: assigning select to sqlquery.sql.text
« Reply #2 on: December 20, 2010, 01:08:22 pm »
Thanks man :)

clauslack

  • Sr. Member
  • ****
  • Posts: 275
Re: assigning select to sqlquery.sql.text
« Reply #3 on: December 20, 2010, 01:40:45 pm »
Sorry
Check for the space after 'like'
sqlquery1.sql.text:='select * from grupist where name like '+
QuotedStr('%'+Trim(edit4.text)+'%');

before then final release check the sql sintax with
ShowMessage(sqlquery1.sql.text);

Regards

 

TinyPortal © 2005-2018