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



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

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变量中获取日期。

将查询更改为此

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

相关内容

  • 没有找到相关文章

最新更新