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是中文的值
[解决办法]
跟那没关系,他用的sqlite数据库,修改时间应该要做处理