在数据库中插入日期 [英] Insertion of date in database
本文介绍了在数据库中插入日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
i我是C#的新手。我正在创建一个网站,其中我有一个用于加入date的文本框。我默认在文本框中使用DateTime.Today.ToString显示日期(yyyy / MM / dd);
我还使用了一个日期选择器。当我使用datepicker更改文本框中的日期时,它总是在数据库中插入今天的日期。我不知道如何插入datepicker选择的日期。 Plz帮助我。
谢谢
Hello,
i am new in C#.I am creating a website in which I have a textbox for joining date.I am showing date by default in textbox using DateTime.Today.ToString("yyyy/MM/dd");
I have also used a datepicker. When I use datepicker to change the date in textbox , It always insert the today's date in database.I dont know how to insert the date selected by datepicker. Plz help me.
Thanks
推荐答案
尝试使用字符串存储日期时间选择器选择的日期
string str = dateTimePicker1.Text;
如果其网络应用程序看到您是否检查过以下情况
if(!IsPostBack)
{
}
如果没有将您的数据库插入该回发块
try using string to store date selected by datetime picker
string str= dateTimePicker1.Text;
if its web application see whether you have checked for following condition
if (!IsPostBack)
{
}
and if not put your database inserting code in that postback block
这篇关于在数据库中插入日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文