Database Connector Error

2019-08-06 03:50发布

I have created a stored procedure for my report..

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
)

And when the Crystal Report dialog box appear asking for parameters, I check all the values to null. But before i proceed to the next step. The error below displayed.

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]

I am hoping that someone here can explain to me why I get this error and how will I do... Im using MS SQL Server 2005 and Crystal Report for VS2010..

thanks in advance. :D

1条回答
虎瘦雄心在
2楼-- · 2019-08-06 03:50

Your parameter names are delimited in the query, so SQL Server is treating them as literal strings. Try

Log_User like @Log_User
   AND Month(Sched_Start) = @Month
   AND Year(Sched_Start) = @Year
查看更多
登录 后发表回答