Board index » delphi » simple query, big problem...

simple query, big problem...

with Delphi 4, Interbase 5.0, an error occurs when I try to execute this :

Query1.SQL.Text := 'insert into MYTABLE (MYFIELD) values ("xxx' : xxx")';
Query1.ExecSQL;

error : "field " is of an unknown type"

with : Query1.SQL.Text := 'insert into MYTABLE (MYFIELD) values ("xxx'
:xxx")'; (no more space after :)
error : "missing right quote"

It seems that Delphi doesn't know what to do with both ' and : characters in
the same string...

Problem is I don't want to use Params property.

Thanks.

Christophe Cerbourg
deca...@wanadoo.fr

 

Re:simple query, big problem...


Pascal uses the ' character to identify the start and end of strings. Try
doubling the ' character to ''

Alternatively use:

Query1.SQL.Text := 'insert into MYTABLE (MYFIELD) values ("xxx' + '''' + ' :
xxx")';

^

Four ' Quotes
Hope it works.

:)

Quote
christophe cerbourg wrote in message <7434qb$20...@platane.wanadoo.fr>...
>with Delphi 4, Interbase 5.0, an error occurs when I try to execute this :

>Query1.SQL.Text := 'insert into MYTABLE (MYFIELD) values ("xxx' : xxx")';
>Query1.ExecSQL;

>error : "field " is of an unknown type"

>with : Query1.SQL.Text := 'insert into MYTABLE (MYFIELD) values ("xxx'
>:xxx")'; (no more space after :)
>error : "missing right quote"

>It seems that Delphi doesn't know what to do with both ' and : characters
in
>the same string...

>Problem is I don't want to use Params property.

>Thanks.

>Christophe Cerbourg
>deca...@wanadoo.fr

Other Threads