Board index » delphi » SQL Queries with Funny Field Names

SQL Queries with Funny Field Names

Hello,

I am writing a small application in Delphi to interface with a large Paradox
v5.0 table.  The table is very big so I am using SQL queries to restrict the
data provided to the user at the time.

The only problem is, one of the fields is named "Building I.D." and Delphi
throws up an error if I use this in the SQL property for my query:

Select * from MyTable where Location = "Bobsville" and Building I.D. = "32876"

EDBError with Message 'Invalid Use Of Keyword. Token: I.D. Line Number: 1'

How can I specify a field name which contains spaces?!
Thanks - please email me as well as posting some news if possible.

  - Bob -

 

Re:SQL Queries with Funny Field Names


Quote
bob.br...@wcs.co.nz wrote:

> Hello,

> I am writing a small application in Delphi to interface with a large Paradox
> v5.0 table.  The table is very big so I am using SQL queries to restrict the
> data provided to the user at the time.

> The only problem is, one of the fields is named "Building I.D." and Delphi
> throws up an error if I use this in the SQL property for my query:

> Select * from MyTable where Location = "Bobsville" and Building I.D. = "32876"

> EDBError with Message 'Invalid Use Of Keyword. Token: I.D. Line Number: 1'

> How can I specify a field name which contains spaces?!
> Thanks - please email me as well as posting some news if possible.

>   - Bob -

Select * from MyTable where Location = "Bobsville" and MyTable."Building I.D." = "32876"

or, if Building I.D. is an Integer:

Select * from MyTable where Location = "Bobsville" and MyTable."Building I.D." = 32876

This should work,
Dominic

Re:SQL Queries with Funny Field Names


Quote
bob.br...@wcs.co.nz wrote:

> Hello,

> I am writing a small application in Delphi to interface with a large Paradox
> v5.0 table.  The table is very big so I am using SQL queries to restrict the
> data provided to the user at the time.

> The only problem is, one of the fields is named "Building I.D." and Delphi
> throws up an error if I use this in the SQL property for my query:

> Select * from MyTable where Location = "Bobsville" and Building I.D. = "32876"

> EDBError with Message 'Invalid Use Of Keyword. Token: I.D. Line Number: 1'

> How can I specify a field name which contains spaces?!
> Thanks - please email me as well as posting some news if possible.

>   - Bob -

Put the field name in quotes (single ['] ot double ["]). This should
work.

Re:SQL Queries with Funny Field Names


On 30 Jul 1996 14:04:40 -0700, bob.br...@wcs.co.nz wrote:

Quote
>Hello,

>I am writing a small application in Delphi to interface with a large Paradox
>v5.0 table.  The table is very big so I am using SQL queries to restrict the
>data provided to the user at the time.

>The only problem is, one of the fields is named "Building I.D." and Delphi
>throws up an error if I use this in the SQL property for my query:

>Select * from MyTable where Location = "Bobsville" and Building I.D. = "32876"

>EDBError with Message 'Invalid Use Of Keyword. Token: I.D. Line Number: 1'

>How can I specify a field name which contains spaces?!
>Thanks - please email me as well as posting some news if possible.

>  - Bob -

Try putting the field name in Quotes.  If you can, change the Field
Name, its a really bad idea to have special characters in field names.

Brien King
bk...@primenet.com

Other Threads