Sql错误 - 由于列名称中的空格

时间:2022-03-26 02:28:00

I am getting errors in a query and I think its just because of the blank spaces in the field names.

我在查询中遇到错误,我认为这只是因为字段名称中的空格。

  rs.Open "SELECT [Sheet1$].Description,[Sheet1$].Security FROM [Sheet1$]", cn, adOpenKeyset, adLockReadOnly

  rs.Open "SELECT [Sheet1$].Description,[Sheet1$].(SEC 1) FROM [Sheet1$]", cn, adOpenKeyset, adLockReadOnly

The first one runs fine, but the second one doesn't and basically throws error about "SEC 1" . Now all of these are column names and cannot be changed, so is there any thing which can solve it. Even putting column name in parenthesis is not working.

第一个运行正常,但第二个运行不正常,并且基本上抛出了关于“SEC 1”的错误。现在所有这些都是列名,无法更改,所以有什么东西可以解决它。即使将列名放在括号中也行不通。

1 个解决方案

#1


3  

You need square brackets, not parenthesis.

你需要方括号,而不是括号。

Change (SEC 1) to [SEC 1].

将(SEC 1)更改为[SEC 1]。

#1


3  

You need square brackets, not parenthesis.

你需要方括号,而不是括号。

Change (SEC 1) to [SEC 1].

将(SEC 1)更改为[SEC 1]。