Put a Variable in a SQL String

Question:

How can I put a variable in a SQL string? For example:

input:=edit1.text;query1.sql.add('select * from address where name like <%variable input%>');

Answer:

Since SQL.Add takes a string, all you need to do is simple string concatenation:

var  qryVar : String;begin  ...  SQL.Add('select * from address ' +          ' where name like ''' + qryVar + '''');

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: