错误-不允许从数据类型日期时间到十进制的隐式转换 [英] Error - Implicit conversion from data type datetime to decimal is not allowed

查看:288
本文介绍了错误-不允许从数据类型日期时间到十进制的隐式转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在以下代码行中收到此错误
不允许从数据类型日期时间到十进制的隐式转换.使用CONVERT函数运行此查询."
有人可以帮我解决这个问题吗?我需要正确的格式. :(


我尝试了所有这三种方式,但没有任何效果:(请帮助

I get this error in the following code line
"Implicit conversion from data type datetime to decimal is not allowed. Use the CONVERT function to run this query."
Can anybody help me to coorect this?? I need the correct format. :(


I tried in all these 3 ways, but nothing worked :( Please help

string cJoinD = DateTime.Now.ToShortDateString();
cmdupd.Parameters.Add(new SqlParameter("@JoinDate", SqlDbType.DateTime));
cmdupd.Parameters["@JoinDate"].Value = cJoinD;







cmdupd.Parameters.Add(new SqlParameter("@JoinDate", SqlDbType.DateTime));
cmdupd.Parameters["@JoinDate"].Value = DateTime.Today;







cmdupd.Parameters.Add(new SqlParameter("@JoinDate", SqlDbType.DateTime));
cmdupd.Parameters["@JoinDate"].Value = Convert.ToDateTime(dtpJoinDate.Text);;

推荐答案

尝试以下操作:

http://stackoverflow.com/questions/425870/在存储过程格式错误中使用datetime-in-a-sqlparameter [
Try this:

http://stackoverflow.com/questions/425870/using-datetime-in-a-sqlparameter-for-stored-procedure-format-error[^]




试试这个:

Hi,

try this:

cmdupd.Parameters.Add(new SqlParameter("@JoinDate", SqlDbType.DateTime));
cmdupd.Parameters["@JoinDate"].Value = DateTime.Today.ToString("YYYYMMDD",CultureInfo.CreateSpecificCulture("en-US"));



有关更多信息,请阅读此线程:

http://stackoverflow.com/questions/336226/string-to-datetime-conversion- in-c [^ ]



for more information read this thread:

http://stackoverflow.com/questions/336226/string-to-datetime-conversion-in-c[^]


请检查数据库表/SP"字段(JoinDate)是否为DateTime字段.我有一种强烈的感觉,不是.
Please check the Database Table/SP field (JoinDate) is a DateTime field. I am having a strong feeling that it is not.


这篇关于错误-不允许从数据类型日期时间到十进制的隐式转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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