从MS Access到VB Net的SQL查询错误

时间:2018-03-10 17:07:50

标签: sql vb.net ms-access

这个查询有什么问题?,我在我的vb net app中运行它,但是我得到了#34;语法错误(缺少运算符)",我从访问2016应用程序生成的工作sql查询中复制了。

查询:

        Dim sqlquery As String = "Select tblCommissionsP.IDCommissionP, tblCategoryProducts.Nama, tblEmployees.Nama, tblCommissionsP.CommissionType, tblCommissionsP.CommissionRate
                            FROM tblCommissionsP INNER JOIN tblCategoryProducts On tblCommissionsP.IDCategoryProduct = tblCategoryProducts.IDCategoryProduct INNER JOIN tblEmployees On tblCommissionsP.IDEmployee = tblEmployees.IDEmployee"

错误:

System.Data.OleDb.OleDbException: 'Syntax error (missing operator) in query expression 'tblCommissionsP.IDCategoryProduct = tblCategoryProducts.IDCategoryProduct INNER JOIN tblEmployees On tblCommissionsP.IDEmployee = tblEmployees.IDEmploye'.'`enter code here`

2 个答案:

答案 0 :(得分:0)

尝试将代码修改为:

Dim sqlquery As String = "Select tblCommissionsP.IDCommissionP, tblCategoryProducts.Nama, tblEmployees.Nama, tblCommissionsP.CommissionType, tblCommissionsP.CommissionRate" _
                       & " FROM tblCommissionsP INNER JOIN tblCategoryProducts On tblCommissionsP.IDCategoryProduct = tblCategoryProducts.IDCategoryProduct INNER JOIN tblEmployees On tblCommissionsP.IDEmployee = tblEmployees.IDEmployee"

答案 1 :(得分:0)

它现在有效,因为不止一个内连接,所以我必须放括号

 (tblCommissionsP INNER JOIN tblCategoryProducts ON tblCommissionsP.IDCategoryProduct = tblCategoryProducts.IDCategoryProduct) INNER JOIN ...