我想从 Sqlite 数据库中读取一个日期时间值并将其分配给 datepicker 控件。这是我正在尝试的代码:
try
{
sqlitecon.Open();
string Query = "Select * from Customer_New where Cust_Id='" + val + "' ";
SQLiteCommand createCommand = new SQLiteCommand(Query, sqlitecon);
// createCommand.ExecuteNonQuery();
SQLiteDataReader dr = createCommand.ExecuteReader();
while(dr.Read()){
date_open.DisplayDate = Convert.ToDateTime(dr.GetString(0));
Date_Joining.DisplayDate = Convert.ToDateTime(dr.GetString(1));
txt_Title.Text = dr.GetString(3);
}
sqlitecon.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
但它给出了错误specified cast is not valid
。直到现在下面给出的两个解决方案都没有工作