使用日期时间作为存储过程的参数更新表错误 [英] Error in Updating a table using datetime as parameter in Stored procedure

查看:218
本文介绍了使用日期时间作为存储过程的参数更新表错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

这篇关于使用日期时间作为存储过程的参数更新表错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆