Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error in FROM clause 1

Status
Not open for further replies.

RSieffert

Programmer
Oct 10, 2002
8
US
I'm trying to use ADOExpress to connect with an Access database. It works fine except when the table name is "national", then I get the error "syntax error in FROM clause" when I try to open the table. Any ideas?
 
AFAIK "national" is not a reserved word in Access. Syntax errors usually occur when you are building the SQL statement from bits of string expressions and forget to include spaces around key words. E.g. using 'FROM' instead of ' FROM ' and 'WHERE' instead of ' WHERE '.

 
Let me be more specific: the "national" table appears in the TableName drop-down list in the ADOTable component along with my other Access tables. If I select any other table from the list and then change Active to True it works fine. But if I pick "national" from the table list I get the "syntax error in FROM clause" error. It seems to me I should be able to select any table that appears in the drop-dlown list.

I also know it can't be a data problem or a table structure problem because I created a simple table with one column and one row which opens without a problem as long as I don't call it "national".
 
Fascinating! I was able to reproduce the problem with Access 97. However, a table name "NATIONAL" works just fine with Gupta SQLBase.

I was able to get connected to "NATIONAL" in Access by setting "TableDirect" to True in the TADOTable component. Perhaps you can use that as a work-around.

I would suggest posting a question in one of the Access forums to see if anyone over there has run into this before.
 
Your TableDirect suggestion will work in this specific situation, but I would really like to know what the real problem is. Sounds like a bug in the code in the ADOTable component that constructs the SELECT command.

Thanks for the help.
 
Hi,
like for any other keywords, you can access this table
with the Query:

Select * From [National]
instead of
Select * From National


So,
AdoTable1.TableName:='[National]';
works perfectly.

This trick works also with fields:
you can make a field named 'Sum' and access it by Select [Sum]
or a field 'e-Mail' (with minus sign) and use it [e-Mail],
but I suggest you to use Non-keyword names.

Ciao,
GeppoDarkson.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top