Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Problem with memo fields and sql
Sun, Oct 26 2008 7:00 PMPermanent Link

"Marcio Ehrlich"
Something weird happened after I've formatted my HD and reinstalled my
system.
I am not being able anymore to insert or update memo fields with a run-time
query, from another query content.
I have this code:

SQL.Add('INSERT INTO "Actions" (Action, Check, Code)');
SQL.Add('VALUES (' + QuotedStr(Query1.FieldByName('Action').AsString) + ', '
+
                    Query1.FieldByName('Check').AsBoolean + ', ' +
                    QuotedStr(Query1.FieldByName('Code').AsString + ')');

And I get:

INSERT INTO "Actions" (Action, Check, Code)
VALUES ('Call suppliers.'#$D#$A'Ask budget', False, '001')

This is raising an error, because of the quotes inside the memo information.

For the record, Query1 is not only open as the memo field content is being
displayed in a DbMemo.

What is going wrong? This code used to work!!

T.I.A.
Marcio Ehrlich

Mon, Oct 27 2008 12:33 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Marcio,

What error message do you get?
As far as I can see, your code has 2 compile-time errors:

> SQL.Add('VALUES (' + QuotedStr(Query1.FieldByName('Action').AsString) + ', '+
>                      Query1.FieldByName('Check').*AsBoolean #1#* + ', ' +
>                      QuotedStr(Query1.FieldByName('Code').AsString *#2#* + ')');


#1# : it should be ".AsString"
#2# : missing ")"

--
Fernando Dias
[Team Elevate]
Mon, Oct 27 2008 2:46 PMPermanent Link

Marcio Ehrlich
Those were just typos, there is no compile-time error, only run-time, when executing the
query created at run-time:

INSERT INTO "Actions" (Action, Check, Code)
VALUES ('Call suppliers.'#$D#$A'Ask budget', False, '001')

It seems it is not accepting 'Call suppliers.'#$D#$A'Ask budget' as the content for the
memo-field, although that information came from another memo field!

I thought that the query should read everything separated by the commas, but it seems it
stops when it finds the single quote before the #$D.

Marcio

Fernando Dias <fernandodias.removthis@easygate.com.pt> wrote:

What error message do you get?
As far as I can see, your code has 2 compile-time errors:
Mon, Oct 27 2008 3:13 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Marcio,

> Those were just typos, there is no compile-time error, only run-time, when executing the

Ah! I see. You must replace QuotedStr() with
DBISAMEngine.QuotedSQLStr(), as follows:

SQL.Add('INSERT INTO "Actions" (Action, Check, Code)');
SQL.Add(
  'VALUES (' +
  Engine.QuotedSQLStr(Query1.FieldByName('Action').AsString) + ', ' +
  Query1.FieldByName('Check').AsString + ', ' +
  QuotedStr(Query1.FieldByName('Code').AsString) + ')'
);

>
> INSERT INTO "Actions" (Action, Check, Code)
> VALUES ('Call suppliers.'#$D#$A'Ask budget', False, '001')
>
> It seems it is not accepting 'Call suppliers.'#$D#$A'Ask budget' as the content for the
> memo-field, although that information came from another memo field!
>
> I thought that the query should read everything separated by the commas, but it seems it
> stops when it finds the single quote before the #$D.
>
> Marcio
>
> Fernando Dias <fernandodias.removthis@easygate.com.pt> wrote:
>
> What error message do you get?
> As far as I can see, your code has 2 compile-time errors:
>

--
Fernando Dias
[Team Elevate]
Mon, Oct 27 2008 5:58 PMPermanent Link

Marcio Ehrlich
WOW! Thanks a BIG lot.
That did it.

Marcio
P.S.: Obrigadão mesmo!!

Fernando Dias <fernandodias.removthis@easygate.com.pt> wrote:

You must replace QuotedStr() with
DBISAMEngine.QuotedSQLStr()
Image