我正在调试以下代码并获得异常:查询表达式'data1.PS NO = data2.PS N'中的语法错误(缺少运算符) .
代码是:
If data1 Is Nothing And data2 Is Nothing Then
MsgBox("Open two excel files to generate report", MsgBoxStyle.Information, "Try Again")
Else
cntcn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'"
oleConnection = New System.Data.OleDb.OleDbConnection(cntcn)
oleCommand = New System.Data.OleDb.OleDbDataAdapter("SELECT May FROM [data1] INNER JOIN [data2] ON data1.PS NO=data2.PS NO WHERE data1.Month = 'May'", oleConnection)
oleCommand.Fill(data3)
End If
这里我创建了两个数据表data1和data2并应用了内连接查询 . 但是得到了上面的异常请帮忙 . 提前致谢 .
1 回答
问题:
您有:
SELECT May
更改为data1.[Month]
更改:
data1.PS NO
至:data1.[PS NO]