Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Relational Databases
Expertise: Beginner
Jul 12, 1999

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 + '''');
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap