使用日期时间作为存储过程的参数更新表错误存储过程、错误、参数、日期

2023-09-03 01:39:08 作者:摇床尖叫雅蠛蝶

CHAR数据类型为DateTime数据类型的转换导致超出范围的日期时间值。 该语句已终止。

The conversion of a char data type to a DateTime data type resulted in an out-of-range DateTime value. The statement has been terminated.

ALTER PROCEDURE [dbo].[attendance_updatebyemployee_id]
@Employee_id int,
@AtDate datetime,
@FNLogged bit,
@ANLogged bit,
@LogTime varchar(10),
@LogOuttime varchar(10) 

AS
BEGIN   


    SET NOCOUNT ON;    
    update Mst_Attendance set FNLogged=@FNLogged,
    ANLogged=@ANLogged,LogTime=@LogTime,LogOuttime=@LogOuttime 
    where EmployeeId=@Employee_id and Atdate= @AtDate

END

在C#code我给它

in C# Code i give it as

 cmd.Parameters.AddWithValue("@AtDate",Dtime.ToString("dd/MMM/yyyy"));

在使用推移,SQL profiler.the数据

while using SQl profiler.the data passed is

exec [dbo].[attendance_updatebyemployee_id] @Employee_id=2,@AtDate='Feb 19 2011 12:00:00:000AM',@FNLogged=1,@ANLogged=0,@LogTime='11:45 AM',@LogOuttime=' ' 

存储过程的@AtDate具有价值里面 2011-02-19 00:00:00.000 它是从这个更新命令破

inside the stored procedure the @AtDate has value 2011-02-19 00:00:00.000. it is breaking from the update command.

里面的日期将被保存为 2011年2月19日上午12点00分○○秒

Inside the table the date is saved as 2/19/2011 12:00:00 AM

我该如何解决这个日期的问题。

How can i solve this date problem.

推荐答案

如果你有工具使用的 SQL事件探查器以实际看到确切 SQL传递给数据库的字符串。这将帮助你找到错误。

If you have the tool use the SQL Profiler to actually see the exact SQL string that is passed to the database. This will help you to find the error.

 
精彩推荐
图片推荐