这意味着实际算术溢出错误将表达式转换为数据类型datetime。 [英] What this mean actually arithmetic overflow error converting expression to data type datetime.

查看:88
本文介绍了这意味着实际算术溢出错误将表达式转换为数据类型datetime。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将表达式转换为数据类型datetime的算术溢出错误。





我有什么试过:



SqlCommand cmd1 =新的SqlCommand(插入Attendence值(@ Engi_Profile_ID,@ In_Date_Time,@ In_Date_Only,@ Out_Date_Time,@ Reason,@备注,@ Flag),con);





{

SqlCommand cmd1 = new SqlCommand(插入Attendence值(@ Engi_Profile_ID,@ In_Date_Time,@ In_Date_Only,@ Out_Date_Time,@ Reason,@ Remark,@ Flag),con);

cmd1.Parameters.AddWithValue(@ Engi_Profile_ID, txtID.Text.ToString());



}



cmd1.ExecuteNonQuery();然后给出错误实际上算术溢出错误将表达式转换为数据类型datetime。

解决方案

这意味着你试图放入datetime参数的任何东西都太大了。只需调试代码,您就会看到值是什么。非常快速且易于修复。


使用DateTime.TryParse或DateTime.TryParseExact(例如google)将txtID.Text转换为DateTime类型,并将DateTime变量添加到参数中。

Arithmetic overflow error converting expression to data type datetime.



What I have tried:

SqlCommand cmd1 = new SqlCommand("insert into Attendence values(@Engi_Profile_ID,@In_Date_Time,@In_Date_Only,@Out_Date_Time,@Reason,@Remark,@Flag)", con);


{
SqlCommand cmd1 = new SqlCommand("insert into Attendence values(@Engi_Profile_ID,@In_Date_Time,@In_Date_Only,@Out_Date_Time,@Reason,@Remark,@Flag)", con);
cmd1.Parameters.AddWithValue("@Engi_Profile_ID", txtID.Text.ToString());

}

cmd1.ExecuteNonQuery(); then give error actually Arithmetic overflow error converting expression to data type datetime.

解决方案

It means whatever you are trying to put into a datetime parameter is way too big. Just debug your code and you'll see what the values are. Pretty quick and simple to fix.


Convert txtID.Text to a DateTime type using DateTime.TryParse, or DateTime.TryParseExact (google for examples) and add the DateTime variable to the parameter instead.


这篇关于这意味着实际算术溢出错误将表达式转换为数据类型datetime。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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