特殊字符和表名空间,造成VBA数据库连接错误 [英] Special character and spaces in table name causing VBA database connection error
问题描述
我在连接到一个名为
,因为它既有空间和名称中的冒号。 访问
数据库表的问题TBL:每日销售
I'm having an issue connecting to a Access
database table called tbl: Daily Sales
because it has both spaces and a colon in the name.
否则,当我连接到一个表不包含空格或特殊字符的名称连接到同一个数据库工程。
Otherwise the connection to the same database works when I connect to a table with a name containing no spaces or special characters.
我不能更改表名。
我如何逃脱表名?
推荐答案
在以方括号表名是很好的做法,并在必要时特殊字符(包括空格)都在表名。无论是括号内为表名。请记住,括号内不限于表名,但字段名称为好。
Enclosing table names in brackets is good practice and is necessary when special characters(including spaces) are in the table name. Whatever is inside the brackets is the table name. Keep in mind, brackets are not limited to table names, but field names as well.
[TBL:每日销售] [FLD:金额]
[tbl: Daily Sales].[fld: Amount]
有关详细信息。 这里: []括号中的sql语句的 或在这里: <一href="http://stackoverflow.com/questions/52898/what-is-the-use-of-the-square-brackets-in-sql-statements">What是用方括号[] SQL语句? 或在这里: <一href="http://stackoverflow.com/questions/9917196/meaning-of-square-brackets-in-ms-sql-table-designer">Meaning方括号[]在MS-SQL表设计?
For more info. Here: [] brackets in sql statements or here: What is the use of the square brackets [] in sql statements? or here: Meaning of square brackets [] in MS-SQL table designer?
这篇关于特殊字符和表名空间,造成VBA数据库连接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!