该字符串未被识别为有效的 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里的值