日期时间更新问题 [英] datetime updating problem- reg

查看:98
本文介绍了日期时间更新问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

更新记录时,日期时间选择器和数据库数据时间数据类型有问题.有人可以建议我如何处理要在Sqlserver中插入和更新的日期时间选择器数据值吗?

谢谢和问候,
A.Harisankar

Dear All,

I have a problem with datetime picker and database datatime datatype while updating my record. can any one suggest me that How to handle datetime picker datavalue to insert and update in Sqlserver?

Thanks and regards,
A.Harisankar

推荐答案

目前,我可以想到2种可能的方法:
1)使用标准的数据库日期时间格式(yyyy/mm/dd hh:mm:ss)(例如2010/12/31 23:59).
2)在查询中使用参数.因此,您将能够直接将日期时间选择器的值分配给该参数.
希望对您有所帮助.
For the moment, I can think 2 possible ways:
1) Use standard database date time formats (yyyy/mm/dd hh:mm:ss) (eg. 2010/12/31 23:59).
2) Use parameters with your query. Thus, you will able to assign the value of date time picker directly to the parameter.
Hope this helps.


对于DateTime值,您可以使用以下内容:
For DateTime values you can use something like the following:
SqlParameter p1 = cmd.Parameters.Add("@SelectedDate", SqlDbType.DateTime);
p1.Value = dateTimePicker.Value;


在sql server中,如果数据类型为datetime,则必须以mm/dd/yyyy格式传递datetime选择器值.因此,所选日期应为mm/dd/yyyy格式.如果仍然无法获取解决方案,请告诉我
In sql server if the Datatype is datetime, you have pass the datetime picker value in mm/dd/yyyy format. So the selected date should be mm/dd/yyyy format.. if are stil not able to get solution let me know


这篇关于日期时间更新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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