我有一个SQLite表,其整数字段为“ starttime”,且具有:
create table if not exists testtable(StartTime integer, ...
我以这种方式用SQLiteParamter插入数据-startTime是DateTime值:
insert into testtable (StartTime, ...) values (@StartTime, ...)
SQLiteParameter("StartTime", startTime)
...
这很好用,如果我将数据库浏览器用于SQLite(https://sqlitebrowser.org),它将显示正确的日期时间。到目前为止一切正常-但是我如何查询该数据并将其转换回日期时间值?
我这样尝试过:
foreach (DataRow row in data.Rows)
{
ListViewItem item = new ListViewItem();
item.Text = row.Field<long>("starttime").ToString();
listViewFlights.Items.Add(item);
}
但是随后我只得到了2019(整个datetime-年的一部分),而不是整个DateTime。但这一定有可能。 SQLite的数据库浏览器向我显示了此数据的完整DateTime-例如:2019-01-15 10:59:42.9883814