Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql problem

Status
Not open for further replies.

s_s_s

Programmer
Feb 6, 2021
1
IR
Hi
Please help me implement the equivalent of the following command in Delphi

'select * from bimar WHERE bimar.fname LIKE '+ QuotedStr ('*') +'&'+ QuotedStr (Edit1.Text) +'&'+ QuotedStr ('*')
 
What have you tried?
What problem are you having?
What database are you using?

Your statement seems wrong. It generates something like:
Code:
select * from bimar WHERE bimar.fname LIKE ''*''&''VALUE''&''*''
where VALUE is the value in Edit1.Text.
Your SQL would probably be better like:
Code:
'select * from bimar WHERE bimar.fname LIKE ' + QuotedStr ('*' + Edit1.Text +'*');
which gives a statement like:
Code:
select * from bimar WHERE bimar.fname LIKE '*VALUE*'

That being said, your should probably use parameters. It protects better from SQL injection.


Mirtheil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top