I am working on a C# WPF project which uses an SQLite database. I am trying retrieving the data from a table within the sqlite database and add to a data set so I can add the data set to the items source of the data grid. One of the columns is a DateTime column but I am getting the following error:
String was not recognized as a valid DateTime.
Below is how I am retrieving the data
private DataSet getAlarmsForSqlite()
{
DataSet ds = new DataSet();
try
{
using (ConnectSQLiteDatabase db = new ConnectSQLiteDatabase(dbPassword))
{
string query = "SELECT * FROM alarms ORDER BY date";
SQLiteDataAdapter da = new SQLiteDataAdapter(query, db.conn);
da.Fill(ds);
}
}
catch (SQLiteException ex)
{
Console.WriteLine("Failed to get alarms. Sqlite Error: {0}", ex.Message);
return null;
}
return ds;
}
And below is the create statement for the table
CREATE TABLE `alarms` (`id` int(11) NOT NULL, `date` datetime NOT NULL,
`type` varchar(50) NOT NULL,
`message` mediumtext NOT NULL,
`level` varchar(45) NOT NULL,
`page` varchar(500) NOT NULL,
`acknowledged` char(1) DEFAULT '0', PRIMARY KEY (`id`))
Thanks for any help you can provide.