该字符串未被辨别为有效的 DateTime
该字符串未被识别为有效的 DateTime。
String conn = @"Data Source=po-pc;Initial Catalog=aspnetdb;User ID=sa;Password=123";
SqlConnection connstring = new SqlConnection(conn);
connstring.Open();
string st1 ="+DropDownList1.Text+";
string st2 ="+ DropDownList2.Text+";[b][/b]
string st3="SELECT * T1 FROM book where booktime="+DropDownList3.Text+"";
DateTime dt1 = Convert.ToDateTime(st1);
DateTime dt2 = Convert.ToDateTime(st2);
DateTime dt3 = Convert.ToDateTime(st3);
if (DateTime.Compare(dt1, dt2) < 0)
{
cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
cn.Open();
SqlCommand cmd = new SqlCommand("UPDATE book SET T1= '" + DropDownList3.Text + "'+'" + DropDownList1.Text + "'+'" + DropDownList2.Text + "'+ '" + TextBox4.Text.Replace("'", "''") + "' where booktime= '" + TextBox1.Text.Replace("'", "''") + "'", cn);
cmd.ExecuteNonQuery();
cn.Close();
这是DropDownList1里的值
String conn = @"Data Source=po-pc;Initial Catalog=aspnetdb;User ID=sa;Password=123";
SqlConnection connstring = new SqlConnection(conn);
connstring.Open();
string st1 ="+DropDownList1.Text+";
string st2 ="+ DropDownList2.Text+";[b][/b]
string st3="SELECT * T1 FROM book where booktime="+DropDownList3.Text+"";
DateTime dt1 = Convert.ToDateTime(st1);
DateTime dt2 = Convert.ToDateTime(st2);
DateTime dt3 = Convert.ToDateTime(st3);
if (DateTime.Compare(dt1, dt2) < 0)
{
cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
cn.Open();
SqlCommand cmd = new SqlCommand("UPDATE book SET T1= '" + DropDownList3.Text + "'+'" + DropDownList1.Text + "'+'" + DropDownList2.Text + "'+ '" + TextBox4.Text.Replace("'", "''") + "' where booktime= '" + TextBox1.Text.Replace("'", "''") + "'", cn);
cmd.ExecuteNonQuery();
cn.Close();
- 1小弟我有一共享打开数据库类,第一次打开时没有异常,以后打开就出现异常,请教高手怎样纠正,多谢
- 2ajax异步登陆页面无法跳转解决办法
- 3web api怎么显示序列化datatable
- 4项目中摘引CodeSmith相关的DLL
- 5Dapper小型ORM的使用(任意吐槽下公司)
- 6asp.net word操作有关问题
- 7替年度评选活动添加倒计时功能
- 8net 调用oracle存储过程(PLS-00306),该怎么解决
- 9如何将部门和子部门在一个listbox中显示
- 10大三在校生的传智120天的1200小时.net(十三)关于Response.Redirect跟Server.Execute的区别
- 上一篇:ASP.NET 异步事件解决方案
- 下一篇:数据显示
文章评论
相关解决方案
- 1该字符串未被识别为有效的 DateTime。该如何解决
- 2该字符串未被识别为有效的 DateTime。 求帮忙解决
- 3此字符串未被识别为有效的DateTime,该如何解决
- 4字符串未被识别为有效的 DateTime解决方法
- 5该字符串未被识别为有效的 DateTime。解决方案
- 6DataSet里增添数据库里的时间类型时弹出"该字符串未被识别为有效的 DateTime"
- 7在WINFORM中使用日历控件出现:该字符串未被识别为有效的 DateTime,该怎么解决
- 8C# Winforms里查询数据库中一列datetime类型变量为什么显示该字符串未被识别为有效datetime?
- 9net2005有关问题 该字符串未被识别为有效的字符串 急
- 10该字符串未被识别为有效的布尔值。哪位高手帮小弟我解决!分给哪位高手