Well, of course it's obvious - but you have to know when to use single or double quotes in order to write such a function (thanks Kyley).

I think I will stick to using params - I've been using a combination up till now.

Thanks both of you for your replies. :)

Phil.

Allan, Samuel wrote:

I hate to state the obvious, but we have a function to set up our
strings for queries. It adds the single-quotes at beginning and end of
string and escapes apostrophes. So that you would create your sql like:

sql := 'field_name = ' + SQLString(someVariable);

That way we don't have to think about setting the string up right, but
also don't have to use parameters if you don't want to. It suits us, but
I don't know if it would suit you.

Samuel



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Phil Middlemiss
Sent: Tuesday, December 13 2005 9:29 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] Single or Double quotes?


Sometimes I can use double quotes when adding a string to an SQL query using Firebird with the Interbase Components. Other times I get an SQL error and have to resort to using single quotes (which is a pain if the string contains an apostrophe).

Can someone set me straight on the conditions under which single or double quotes can be used in a query?

Cheers,
Phil.

_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi



begin:vcard
fn:Phil Middlemiss
n:Middlemiss;Phil
org:Vision Software, MTS Ltd
email;internet:[EMAIL PROTECTED]
title:Project Leader
tel;work:+64 7 3480001
tel;cell:+64 27 4592648
x-mozilla-html:TRUE
url:http://www.tumonz.co.nz
version:2.1
end:vcard

_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to