在数据库中保存日期 [英] save date in database

查看:150
本文介绍了在数据库中保存日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的表单应用程序中,我连接到访问数据库(mydatabase.mdb),并且在表中我具有带有date/time属性的字段,但是,如果使用表单,似乎只能存储文本"或字符串".

我想将日期存储为dd-mm-yyyy,并将其保存为DateTime值而不是字符串.

对于日期输入,我使用DateTimePicker.

它是这样绑定的:
OrderDate.Databinding.Add(new Binding("Text",Connection1.Bindingsource,"OrderDate"));

我希望有人可以帮助我.

Hi,

In my form application I am connected to my access database (mydatabase.mdb) and in a table I have field with the date/time property but it seems that i can only store "Text" or "String" if I use my form.

I want to store the date as dd-mm-yyyy and that it is saved as a DateTime value and not like a string.

For the date input I use a DateTimePicker.

it is binded like this:
OrderDate.Databinding.Add(new Binding("Text",Connection1.Bindingsource,"OrderDate"));

I hope someone can help me.

推荐答案

您可能想再次尝试使用Date,但是这次请确保您的日期范围落在数据库的日期.

DateTime的范围大于MS SQL中允许的日期.
You may want to try using a Date again, but this time make sure that your range of dates falls within the acceptable range of dates for a database.

The range of a DateTime is larger than a date allowable in MS SQL.


这篇关于在数据库中保存日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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