Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to reading a datetime value from a Sqlite database and assign it to datepicker control. Here is my code that i am trying:

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);
txt_cardnum.Text =dr.GetString(4)
}
sqlitecon.Close();


}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

but it is giving error :" specified cast is not valid" .How it can be done ? please help .
Posted
Comments
Member 8920414 9-Oct-13 6:08am    
I have also tried this
date_open.DisplayDate = Convert.ToDateTime(dr.GetString(1));
But it still give error : "string was not recognize as a valid datatime"
Sharma Richa 9-Oct-13 6:57am    
Try to debug it and see what is coming from database

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900