Board index » delphi » SQL works in SQL Explorer but not at runtime

SQL works in SQL Explorer but not at runtime

This SQL tries to store an encrypted string into a string field in a DBase
table:

Update RecTrans
Set Expiry = '},N,E'
, CardNum = 'y)M)F":'
, StartDate = '12/20/2002'
, Status = 'A'
, NextBill = '1/1/2003'
Where RecTransId = 4

This works if entered into the SQL Explorer, but does not work at runtime.
The error reported is:
Invalid use of keyword. Token: 'Y)M)F"? Line Number: 3

The problem appears to be the colon.  If I run the same this without the
last character in the string, it works.  I have ensured "RequestLive" is set
to false prior to this query.

Thanks in advanced

 

Re:SQL works in SQL Explorer but not at runtime


Quote
>This SQL tries to store an encrypted string into a string field in a DBase
>table:

>Update RecTrans
>Set Expiry = '},N,E'
>, CardNum = 'y)M)F":'
>, StartDate = '12/20/2002'
>, Status = 'A'
>, NextBill = '1/1/2003'
>Where RecTransId = 4

>This works if entered into the SQL Explorer, but does not work at runtime.
>The error reported is:
>Invalid use of keyword. Token: 'Y)M)F"? Line Number: 3

>The problem appears to be the colon

Yes the colon is what Delphi uses to designate parameters.
The easiest way to handle this is to use parameters

Update RecTrans
Set Expiry = '},N,E'
, CardNum = :CardNum
, StartDate = '12/20/2002'
, Status = 'A'
, NextBill = '1/1/2003'
Where RecTransId = 4

Then before you open the query us

Query1.ParambyName('CardNum').asString := 'y)M)F":';
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:SQL works in SQL Explorer but not at runtime


Thanks.  Worked like a charm.

Re:SQL works in SQL Explorer but not at runtime


Quote
"Slider" <k...@hotmail.com> wrote in message

news:3e060026$1@newsgroups.borland.com...

Quote
> This SQL tries to store an encrypted string into a string field in a DBase
> table:

> Update RecTrans
> Set Expiry = '},N,E'
> , CardNum = 'y)M)F":'
> , StartDate = '12/20/2002'
> , Status = 'A'
> , NextBill = '1/1/2003'
> Where RecTransId = 4

> This works if entered into the SQL Explorer, but does not work at runtime.
> The error reported is:
> Invalid use of keyword. Token: 'Y)M)F"? Line Number: 3

> The problem appears to be the colon.  If I run the same this without the
> last character in the string, it works.  I have ensured "RequestLive" is
set
> to false prior to this query.

You can also double the colon :: if you need another way.

Jim Cullison

Other Threads