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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.