Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Syntax..SQLEXEC() using ODBC table with a space in the n
Message
From
04/01/2001 17:53:36
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00459586
Message ID:
00459600
Views:
17
>I can't pass an SQL statement due to a syntax error when I use SQLEXEC(). I've connected (using VFP 6)
>to an Access 97 database with a table called 'Budget Contract'. I would love to rename the table, but it won't
>be possible. Here's the problem...
>
>X =SQLEXEC(nh,'SELECT * FROM "BUDGET CONTRACT"') && works fine as long as the double-quotes are
> && within the single quotes, but not vice versa
>

Quoted identifiers (i.e., object names - like tables - in quotes) requires double-quotes in SQL Server - for clarity, you can use square brackets instead of single-quotes in VFP, e.g.
x = SQLEXEC(nh, [select * from "BUDGET CONTRACT"])
>X = SQLEXEC(nh,'INSERT INTO "BUDGET CONTRACT"(EMP_NO) VALUES('9999')') && won't work
> && because it won't accept any quote or space
> && between the table name and EMP_NO field.
>

This isn't because of the quoted-identifier, it's because of the single-quotes around the '9999' and the insert statement - square brackets should definitely fix this one.
Here, you should definitely use the bracket, e.g.
x = SQLEXEC(nh, [insert into "BUDGET CONTRACT" (EMP_NO) VALUES ('9999')])
Insanity: Doing the same thing over and over and expecting different results.
Previous
Reply
Map
View

Click here to load this message in the networking platform