SQL statement exception when MDB table name contains #32
I am using Delphi 7 and am trying to build a SQL query statement which
will be used with a Microsoft Access MDB file. The code is below:
dm.tblUserTableQ.Close;
dm.tblUserTableQ.sql.Clear;
dm.tblUserTableQ.sql.Add('select count(*) as QTY from '+
Tables.items[Tables.itemindex]);
The above code works fine as long as the MDB table name chosen has no #32
space characters in it. IOW, if the table name is named "ZIPCODES", the
query works fine. However, if the table name is named "ZIP CODES", the
sql.Add statement triggers an exception: Syntax error in query. Incomplete
query clause.
I have tried enclosing the table name within #39 characters, but that
doesn't help. IOW:
'select count(*) as QTY from '+ #39 + Tables.items[Tables.itemindex] + #39
I've tried #34, but that doesn't help either.
Other than renaming the table, is there any solution?
No comments:
Post a Comment