日期:2014-05-17  浏览次数:20709 次

DataSet里添加数据库里的时间类型时弹出"该字符串未被识别为有效的 DateTime"
SQLiteConnection con = new SQLiteConnection();              con.ConnectionString = @"Data Source=d:/Patient/Patient.db";              string sqlstr = "select Name,Age,MeasureTime,IsAnalyse from patientinfo";              SQLiteCommand cmd = new SQLiteCommand(sqlstr, con);              SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);              DataSet ds = new DataSet();              da.Fill(ds);//问题出在这里              dataGridView2.DataSource = ds.Tables[0];

string strSQL5 = "update patientinfo set MeasureTime='" + Convert.ToDateTime(dateTimePicker2.Text.Trim()) + "' WHERE ID=" + textBox1.Text + "";                 SQLiteCommand sqlcmd5 = new SQLiteCommand(strSQL5, sqlconn);                 sqlcmd5.ExecuteNonQuery(); 
DataSet

------解决方案--------------------
dateTimePicker2.Value,text是中文的值
------解决方案--------------------
引用:
不是跟你说了吗,.Text的格式是“2013年11月12日……”这种格式的
你把dateTimePicker2.Text改成dateTimePicker2.Value就可以了


跟那没关系,他用的sqlite数据库,修改时间应该要做处理