下面的代码我有两个查询列出stSQL =" SELECT * FROM QA \ Dependencies"和stSQL1 =" SELECT * FROM QA \ QA Priority"如果你看到第一个查询,当我运行它运行顺利,但如果运行另一个查询表名称或你可以查看莲花笔记的名称有空格,它给我一个错误。任何人都可以帮助为Lotus编写一个名称中没有空格的视图。
Option Explicit
Private Sub CommandButton21_Click()
Dim wbBook As Workbook
Dim wsSheet As Worksheet
Dim rnData As Range
Dim adoCN As ADODB.Connection
Dim adoRst As ADODB.Recordset
Dim adoRst1 As ADODB.Recordset
Dim stSQL As String
Dim stSQL1 As String
Dim vaData As Variant
Dim a As String
Set adoCN = New ADODB.Connection
Set wbBook = ThisWorkbook
Set wsSheet = wbBook.Worksheets("Sheet1")
adoCN.Open ("Driver={Lotus NotesSQL Driver (*.nsf)};Database=DATABASE.nsf;Server=Server;")
stSQL = "SELECT * FROM QA\Dependencies"
Set adoRst = adoCN.Execute(stSQL)
stSQL1 = "SELECT * FROM QA\QA Priority"
Set adoRst1 = adoCN.Execute(stSQL1)
adoCN.Close
Set adoRst = Nothing
Set adoRst1 = Nothing
Set adoCN = Nothing
End Sub
答案 0 :(得分:0)
我认为你需要用[]
包围你的表名,如下所示:
stSQL1 = "SELECT * FROM [QA\QA Priority]"
答案 1 :(得分:0)
应引用如下:
stSQL1 = "SELECT * FROM QA\[QA Priority]"
答案 2 :(得分:0)
stSQL1 = "SELECT * FROM QA\[QA Priority]" 'is not working
我试过下面的组合。 stSQL1 =“SELECT * FROM” stSQL2 = stSQL1& “”QA \ QA优先级“”“