代码中的问题... [英] problem in code......

查看:92
本文介绍了代码中的问题...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DateTime localNow = DateTime.Now;
           string postScrap = "Insert INTO Scrap (FromId,ToId,Message,SendDate) VALUES(''" + Session["Id"].ToString() + "'',''" + Request.QueryString["Id"].ToString() + "'',''" + TextBoxScrap.Text + "'',''"+localNow+"'')";
           dbClass.ConnectDataBaseToInsert(postScrap);
          Response.Redirect("UserDetails.aspx?Id=" + Request.QueryString["Id"].ToString());



当日期为2011年6月12日时,它可以正常工作,但是当日期为6月13日时,我为


它给出了错误将char数据类型转换为datetime数据类型导致超出范围的datetime值.
该语句已终止.



SendDate列的数据类型为datetime

when is



When Date is june 12 2011 it works fine but i when set date june 13


it gives error The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.



SendDate column datatype is datetime

when is

推荐答案

看起来像您的服务器日期时间格式和客户端日期时间格式不同尝试将此日期转换为等效的服务器日期时间(http://www.technoreader.com/SQL-Server-Date-Time-Format.aspx [ ^ ]).
Looks like your server datetime format and the client date time format are different Try converting this date into the server datetime equivalent (http://www.technoreader.com/SQL-Server-Date-Time-Format.aspx[^]).


提示:这是什么日期:2011年12月11日?是11月12日还是12月11日?
还是不明白吗?哪个日期无效:18/12/2011或12/18/2011?

还是不明白吗?真的吗?如果是这样,没有任何帮助.

—SA
A hint: what is this date: 12/11/2011? 12th of November or 11th of December?
Still not getting it? Which date is invalid: 18/12/2011 or 12/18/2011?

Still not getting it? Really? If so, nothing can help.

—SA


这篇关于代码中的问题...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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