0x436f72647265
0x436f72647265

Reputation: 455

Adding a quote character in a Delphi String

I am writing a SQL program in Delphi 7 and came across a problem. If you add an SQL command you have to use ' to indicate it is a Variable or String, but I want to build up my SQL statement because it is coming from different If statements and thus have to build it up. Therefore, I wanted to know if anyone knows a trick to add a ' into a string.

Upvotes: 2

Views: 7122

Answers (2)

whosrdaddy
whosrdaddy

Reputation: 11860

Don't make the same mistake like many before you and lookup parametrized queries or else you will be open for SQL injection attacks. If you need to include string constants in your query then use 2 single quotes ('') or the QuotedStr() function from the SysUtils unit.

Upvotes: 6

dKen
dKen

Reputation: 3127

Try two quotes to represent one i.e. ''

Upvotes: 1

Related Questions