查询表达式中的语法错误(缺少运算符):System.Data.OleDb.OleDbException
Syntax error (missing operator) in query expression: System.Data.OleDb.OleDbException
我在 MS Access 2016 中发送以下 SQL 查询作为 ASP WebForm 中的字符串:
string showGridViewQuery = "select creditorName, amount, interestRate, interestType, interestCalculationMethod, insertedDate, o.fullName as owner, u.fullName as dataInsertedBy from tbl_savings s left join tbl_users o on ownerID = o.userID left join tbl_users u on dataEnteredByID = u.userID";
当我 运行 时,出现以下错误:
System.Data.OleDb.OleDbException: Syntax error (missing operator) in query expression 'ownerID = o.userID left join tbl_users u on dataEnteredByID = u.userID'.
当执行到以下代码中的showGridViewCommand.ExecuteNonQuery();
时:
string connectionString = GetConnString();
OleDbConnection con = new OleDbConnection(connectionString);
con.Open();
string showGridViewQuery = "select creditorName, amount, interestRate, interestType, interestCalculationMethod, insertedDate, o.fullName as owner, u.fullName as dataInsertedBy from tbl_savings s left join tbl_users o on ownerID = o.userID left join tbl_users u on dataEnteredByID = u.userID";
OleDbCommand showGridViewCommand = new OleDbCommand(showGridViewQuery, con);
showGridViewCommand.ExecuteNonQuery();
DataTable dt = new DataTable();
OleDbDataAdapter olda = new OleDbDataAdapter(showGridViewCommand);
olda.Fill(dt);
GridViewSavingsTracker.DataSource = dt;
GridViewSavingsTracker.DataBind();
con.Close();
我在这里错过了什么?
经过多次尝试,我找到了正确的解决方案:
string showGridViewQuery = "select savingsID, creditorName, amount, interestRate, interestType, interestCalculationMethod, insertedDate, o.fullName as owner, u.fullName as dataEnteredBy from ((tbl_savings as s) left join tbl_users as o on s.ownerID = o.userID) left join tbl_users as u on s.dataEnteredByID = u.userID";
我知道 MS Access 不好。但不知道它这么糟糕!
我在 MS Access 2016 中发送以下 SQL 查询作为 ASP WebForm 中的字符串:
string showGridViewQuery = "select creditorName, amount, interestRate, interestType, interestCalculationMethod, insertedDate, o.fullName as owner, u.fullName as dataInsertedBy from tbl_savings s left join tbl_users o on ownerID = o.userID left join tbl_users u on dataEnteredByID = u.userID";
当我 运行 时,出现以下错误:
System.Data.OleDb.OleDbException: Syntax error (missing operator) in query expression 'ownerID = o.userID left join tbl_users u on dataEnteredByID = u.userID'.
当执行到以下代码中的showGridViewCommand.ExecuteNonQuery();
时:
string connectionString = GetConnString();
OleDbConnection con = new OleDbConnection(connectionString);
con.Open();
string showGridViewQuery = "select creditorName, amount, interestRate, interestType, interestCalculationMethod, insertedDate, o.fullName as owner, u.fullName as dataInsertedBy from tbl_savings s left join tbl_users o on ownerID = o.userID left join tbl_users u on dataEnteredByID = u.userID";
OleDbCommand showGridViewCommand = new OleDbCommand(showGridViewQuery, con);
showGridViewCommand.ExecuteNonQuery();
DataTable dt = new DataTable();
OleDbDataAdapter olda = new OleDbDataAdapter(showGridViewCommand);
olda.Fill(dt);
GridViewSavingsTracker.DataSource = dt;
GridViewSavingsTracker.DataBind();
con.Close();
我在这里错过了什么?
经过多次尝试,我找到了正确的解决方案:
string showGridViewQuery = "select savingsID, creditorName, amount, interestRate, interestType, interestCalculationMethod, insertedDate, o.fullName as owner, u.fullName as dataEnteredBy from ((tbl_savings as s) left join tbl_users as o on s.ownerID = o.userID) left join tbl_users as u on s.dataEnteredByID = u.userID";
我知道 MS Access 不好。但不知道它这么糟糕!