Recent

Author Topic: " sign  (Read 6845 times)

asdf

  • Sr. Member
  • ****
  • Posts: 310
" sign
« on: November 15, 2010, 11:26:29 am »
Using Firebird,
field1 varchar(100),

No1 : integer;
No2 : string;
readline(textfile1,ln);
SQLQuery.Sql.Text:='update table1 set field1 ='
+ quotedstr(ansitoutf8(ln))
+ 'where id = ' + recID + ')';   

Now SQLQuery.Sql.Text has error.

In VB6 it has ( " ) sign, but overhere we have only ( ' ) - I'm very confused.
Please help rearranging SQLQuery.Sql.Text.
Thank you in advance
                                   
Lazarus 1.2.4 / Win 32 / THAILAND

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: " sign
« Reply #1 on: November 15, 2010, 11:30:34 am »
Sorry

RecID: String;
Lazarus 1.2.4 / Win 32 / THAILAND

JohnvdWaeter

  • Full Member
  • ***
  • Posts: 171
    • http://www.jvdw.nl
Re: " sign
« Reply #2 on: November 15, 2010, 11:51:33 am »
more important:
what does the error say?

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: " sign
« Reply #3 on: November 15, 2010, 12:38:32 pm »
function quotedstr is hardcoded to use single-quote. luckily for you, AnsiQuotedStr is not.

JohnvdWaeter

  • Full Member
  • ***
  • Posts: 171
    • http://www.jvdw.nl
Re: " sign
« Reply #4 on: November 15, 2010, 12:43:05 pm »
or maybe:
SQLQuery.Sql.Text:='update table1 set field1 ='
+ quotedstr(ansitoutf8(ln))
+ 'where id = ' + recID + ')';   

Put a space just before where:

... + ' where id = ' + recID + ')';   

John

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: " sign
« Reply #5 on: November 15, 2010, 04:11:12 pm »
The error is as attached photo....
Lazarus 1.2.4 / Win 32 / THAILAND

JohnvdWaeter

  • Full Member
  • ***
  • Posts: 171
    • http://www.jvdw.nl
Re: " sign
« Reply #6 on: November 15, 2010, 04:17:32 pm »
just as it says: there is a closing bracket ) that should not be there.


SteveF

  • Jr. Member
  • **
  • Posts: 92
Re: " sign
« Reply #7 on: November 15, 2010, 04:30:27 pm »
PMFJI, but Firebird also uses the double-quotes to delimit its table and column names.  The following is a valid Firebird SQL statement:

SELECT * FROM "ORDERS" WHERE "ORDERS"."CUSTNAME" = 'WIDGETS INC';

If you need them in this way, you can always include them in your SQL string by using #34 in the string build to supply the ASCII character.

Steve

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: " sign
« Reply #8 on: November 15, 2010, 04:35:16 pm »
Thank you so much.

In the past with VB6, I always check by MessageBox?
I tried the same overhere, the result is clear.

There was an unimportant '('.

Please use this technique.
Lazarus 1.2.4 / Win 32 / THAILAND

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: " sign
« Reply #9 on: November 15, 2010, 04:41:00 pm »
One more please.

Why RecID did not need quotedstr?
But on the other hand, at quotedstr(ansitoutf8(ln)) - It is a 'must'.
Lazarus 1.2.4 / Win 32 / THAILAND

SteveF

  • Jr. Member
  • **
  • Posts: 92
Re: " sign
« Reply #10 on: November 15, 2010, 05:06:21 pm »
One more please.

Why RecID did not need quotedstr?
But on the other hand, at quotedstr(ansitoutf8(ln)) - It is a 'must'.


Most likely because RecID is numeric, no delimiter needed.  If Field1 is defined as char() or varchar() then the ' delimiters around the value for the column are required to build a valid SQL string.

If you haven't already, you need to take a look at the documentation on the Firebird website for the specific SQL syntax Firebird requires.

Steve

 

TinyPortal © 2005-2018