如何从sqlite数据库中获取字符串变量的日期?

时间:2016-04-05 11:36:21

标签: c# database sqlite date get

我想从sqlite数据库中获取日期。表列名称为“date”,列类型为date。

SQLiteCommand sqlite_cmd;
SQLiteDataReader sqlite_datareader;
sqlite_conn = new SQLiteConnection(sConnectionString);
sqlite_conn.Open();
sqlite_cmd = sqlite_conn.CreateCommand();

sqlite_cmd.CommandText = "Select * from prework where pid = " + iProjectID + " and chainage = " + fChainage + ";";

try
{
    sqlite_datareader = sqlite_cmd.ExecuteReader();
    while (sqlite_datareader.Read())
    {
        String str = sqlite_datareader["date"].ToString();
    }
}
catch
{
    return;
}

我想在str变量中获取日期。

1 个答案:

答案 0 :(得分:0)

将您的查询更改为此

"Select * from prework where pid = '" + iProjectID + "' and chainage = '" + fChainage + "';