我为报告创建了一个存储过程..
create Procedure [dbo].[sp_Score_Grade]
@Month int,
@Year int,
@Log_User varchar(30)
AS
(
SELECT Log_User, Count = COUNT(Det_Score), Score = SUM(Det_Score)
FROM MEMBER M,DETAILS D
WHERE D.Emp_Id = M.Emp_Id AND
Log_User like '@Log_User'
AND Month(Sched_Start) = '@Month'
AND Year(Sched_Start) = '@Year'
GROUP BY Log_User
)
当出现Crystal Report对话框询问参数时,我会检查所有值为null。但在我继续下一步之前。显示以下错误。
Database Connector Error:
Source: Microsoft OLE DB Provider for SQL Server
Description: Conversion failed when converting the varchar value '@Month' to data type int
SQL State: 22018
Native Error: 245[Database Vendor Code: 245]
我希望有人在这里向我解释为什么我会收到这个错误,我该怎么办... 我正在使用MS SQL Server 2005和Crystal Report for VS2010 ..
提前谢谢。 :d答案 0 :(得分:1)
您的参数名称在查询中分隔,因此SQL Server将它们视为文字字符串。尝试
Log_User like @Log_User
AND Month(Sched_Start) = @Month
AND Year(Sched_Start) = @Year