Database Connector Error

强颜欢笑 提交于 2019-12-24 09:27:26

问题


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:


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


来源:https://stackoverflow.com/questions/8600435/database-connector-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!