0
string sql = "select * from User where sUserName = '" + sUserName + "' AND sUserPassword = '" + sUserPassword + "'";
SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
SQLiteDataReader reader = command.ExecuteReader();
if (reader.Read())
{
    DateTime Time = reader.GetDateTime(0);
    System.DateTime timeNow_FromLocal = System.DateTime.Now; 
    if (timeNow_FromLocal < Time)
    {
        return true;
    }
    else
    {
        return false;
    }
}
else
{
    return false;
}

I want to get DateTime from sqlite database to compare with system time, but I can not reader.GetDateTime(0) successfully.

Robert
  • 2,407
  • 1
  • 24
  • 35

1 Answers1

0

try this

DateTime Time = DateTime.Parse(reader["columnName"].ToString());
  • Thanks you very much. I have done it well with the help of you. I spent an afternoon working on my original way but spend little time to do it well by your way.Although I still have doubts about the original method, I intend to finish the project first and then study why it is not right. – WangXinBoy09 Nov 09 '18 at 12:52