【发布时间】:2011-01-20 15:45:55
【问题描述】:
我正在使用 ASP.NET (C#) 和 SQLServer 2008 开发应用程序。在我的数据库中,我有一个字段 DepositDate 并且数据类型是“DATE”。在我的数据输入表单上,我使用 jquery datepicker 获取日期,并根据用户要求将其在文本框中的返回日期作为 dd/mm/yyyy 格式,而我在数据库中注意到它的日期值保持为 yyyy-mm-dd ..我很困惑。
在保存记录时,我得到的日期时间无效,因为唯一可用的转换格式是 Convert.ToDateTime,而我的数据要求仅为 DATE。
任何人都可以提出解决方案如何处理它。?
这里是代码
DateTime thedate = DateTime.Parse(txt_IDate.Text);
DateTime mdate = DateTime.Parse(txt_Mdate.Text);
db.AddInParameter(cmd, "@SIssueDate", System.Data.DbType.Date);
db.SetParameterValue(cmd, "@SIssueDate", thedate.ToShortDateString());
db.AddInParameter(cmd, "@SMaturityDate", System.Data.DbType.DateTime);
db.SetParameterValue(cmd, "@SMaturityDate", mdate.ToShortDateString());
【问题讨论】:
标签: asp.net