我使用这个sql语句来产生所需的结果。并希望通过数据集(.xsd)使用rdlc在C#中的报表中显示这些结果查询。
SELECT pay.Cutoff,
emp.Id,
emp.LastName,
emp.FirstName,
emp.MiddleName,
emp.TinNumber,
job.Rate * 25 AS FixBIR,
(SELECT COUNT(*) AS MonthsWorked
FROM payroll AS pay3
WHERE YEAR(pay3.DateGenerated) = 2014
AND pay3.EmployeeId = 1
AND pay3.Cutoff = 1
ORDER BY MONTH(pay3.DateGenerated) ASC) * (job.Rate * 25)
AS MonthsWorked_FixBIR_TODATE,
pay.TaxWithheld,
(SELECT SUM(payroll2.TaxWithheld) AS TaxTotal
FROM employee AS employee2
INNER JOIN payroll AS payroll2
ON employee2.Id = payroll2.EmployeeId
WHERE (payroll2.Cutoff = 1)
AND (employee2.Id = emp.Id)
AND YEAR(payroll2.DateGenerated) = 2014)
AS Tax_TODATE,
YEAR(pay.DateGenerated) AS YEAR
FROM employee AS emp
INNER JOIN payroll AS pay
ON emp.Id = pay.EmployeeId
INNER JOIN job
ON emp.JobId = job.Id
WHERE pay.Cutoff = 1
AND pay.PayrollMonth = 'August'
AND Year(pay.DateGenerated) = 2014
此声明正常(在navicat中测试)。
然而,当我使用查询生成器将其转移到数据集时,它不起作用。错误说:
在配置TableAdapter时,向导会检测到以下问题:"填充"详细说明:
!生成的SELECT语句 SELECT子句出错:表达式附近' SELECT' SELECT子句出错:表达式附近' FROM' 缺少条款 SELECT子句出错:表达式附近','。 无法解析查询文本
如果我尝试在SELECT语句中使用简单的子查询,则会出现错误:
无法在图表和标准窗格中以图形方式表示查询。
如何在rdlc中使用sql语句?除了数据集中的查询构建器之外还有其他方法吗?