devxlogo

Put a Variable in a SQL String

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 ');

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 + '''');

devx-admin

Share the Post: