我有一个在运行 SQL Server CE 的 Windows Mobile 上运行的现有应用程序,并且正在使用 C# 语言的内联查询。这是我在 Management Studio 中正常工作的查询:
command = @"SELECT
P_InspectionStep.InspectionStepID,
P_InspectionStep.Sequence AS Sequence,
P_InspectionStep.Title AS Title,
P_InspectionStep.Body AS Body,
P_InspectionStep.Photo AS Photo,
P_Inspection.RevisionID
FROM
P_InspectionStep
LEFT JOIN
P_Inspection ON P_Inspection.InspectionID = P_InspectionStep.InspectionID
WHERE
P_Inspection.InspectionID = '" + mInspectionID + "'" +
@"AND P_Inspection.CreateDate = (SELECT MAX(P_Inspection.CreateDate) FROM P_Inspection)
UNION ALL
SELECT
C_InspectionStep.InspectionStepID,
C_InspectionStep.Sequence AS Sequence,
C_InspectionStep.Title AS Title,
C_InspectionStep.Body AS Body,
C_InspectionStep.Photo AS Photo,
C_Inspection.RevisionID
FROM
C_InspectionStep
LEFT JOIN
C_Inspection ON C_Inspection.RevisionID = C_InspectionStep.RevisionID
WHERE
C_Inspection.InspectionID = '" + mInspectionID + "'" +
@"AND C_Inspection.CreateDate = (SELECT MAX(C_Inspection.CreateDate) FROM C_Inspection)
ORDER BY 2;";
但是在应用程序中运行它会返回SqlCeException
:
解析查询时出错。[令牌行号= 10,令牌行偏移量= 132,错误令牌= SELECT]
我已经做了很多搜索,但无法找到如何解决这个问题。