![](/img/trans.png)
[英]How do I insert and query a DateTime object in SQLite DB from C#?
[英]How do I get a DateTime value from sqlite row in c#
我在这里阅读了很多问题,并没有给出解决方案,并且我尝试了使用sqlite datetime(...)或strftime()的多种尝试(尽管不确定后者是否在c#中被识别),以尝试提取数据一组来自单行的列值,但日期字段未返回任何字符串,而数字列也很好。 通过检查手表可以证明dt.Rows [0] [“ ResponseDateTime”]谁能指出我哪里出了问题? 曾尝试过:(以及其他)
从表中选择字段1,strftimetime('%d /%m /%Y%H:%M',resDateTime)作为ResponseDateTime,字段2
从表中选择field1,datetime(resDateTime),field2
等等
public DataTable GetDataTable(string sql)
{
DataTable dt = new DataTable();
try
{
//with the following the date field is not getting any date datat into the field
// SQLiteConnection cnn = new SQLiteConnection(dbConnection);
// SQLiteCommand command = new SQLiteCommand(sql, cnn);
// cnn.Open();
// SQLiteDataAdapter myAdapter = new SQLiteDataAdapter(command);
// myAdapter.Fill(dt);
SQLiteConnection cnn = new SQLiteConnection(dbConnection);
cnn.Open();
SQLiteCommand dbCommand = cnn.CreateCommand();
dbCommand.CommandText = sql;
SQLiteDataReader executeReader = dbCommand.ExecuteReader(CommandBehavior.SingleResult);
dt.Load(executeReader); // <-- FormatException
cnn.Close();
}
catch (Exception crap)
{
OutCrap(crap);
//throw new Exception(crap.Message);
}
return dt;
}
Aha 从数据库IOS的日期之间获取了与相关的sqlite提取日期相关的问题,事实上,在进行了所有更改之后, IOS回答了这个问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.