当使用C#中的以下SQL语句/ OleDbCommand.ExecuteReader我得到一个语法错误在FROM子句。 在MS Access中使用完全相同的语句直接正常工作。使用C#OleDb的,但在接入号码错误相同的查询“FROM子句语法错误”本身
SELECT
s.idShots, s.shotdata, c.[original], s.[hash], comp.idCompetitions, comp.competitionsname, sh.idShooters, sh.firstname, sh.lastname
FROM (([Shots] s
INNER JOIN [ShotsCertificate] c ON c.[uuid] = s.[uuid])
INNER JOIN [Competitions] comp ON comp.idCompetitions = s.fidCompetitions)
INNER JOIN [Shooters] sh ON sh.idShooters = s.fidShooters ORDER BY s.idShots ASC
在C#:
OleDbCommand cmd2 = new OleDbCommand("", dbc);
cmd2.CommandText = "SELECT s.idShots, s.shotdata, c.[original], s.[hash], comp.idCompetitions, comp.competitionsname, sh.idShooters, sh.firstname, sh.lastname FROM" +
" (([Shots] s" +
" INNER JOIN [ShotsCertificate] c ON c.[uuid] = s.[uuid])" +
" INNER JOIN [Competitions] comp ON comp.idCompetitions = s.fidCompetitions)" +
" INNER JOIN [Shooters] sh ON sh.idShooters = s.fidShooters" +
" ORDER BY s.idShots ASC";
log.Debug(cmd2.CommandText);
OleDbDataReader r = cmd2.ExecuteReader();
在DBC的连接工作正常,它在一些以前的命令使用,一切正常。
感谢您的建议!
为[射击],[ShotsCertificate],[赛事]和[射击]所有表,或者是一个或更多他们在Access中保存的选择查询? –
尝试在别名前使用'As'。 – Gustav
都是正常的表,没有观点或东西 – Christopher