in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

SQLiteReader.GetDateTime(string columnName)

Last post 10-21-2009 4:08 AM by Yurik. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 10-20-2009 7:42 AM

    • Yurik
    • Top 100 Contributor
    • Joined on 08-04-2009
    • Posts 14

    SQLiteReader.GetDateTime(string columnName)

     Now you have only GetDateTime(columnIndex) what forces me to hardcode column index or to go through all columns to search for the required name.

  • 10-20-2009 11:43 PM In reply to

    • Nate
    • Top 10 Contributor
    • Joined on 08-28-2005
    • Fort Collins, CO
    • Posts 93

    Re: SQLiteReader.GetDateTime(string columnName)

    http://msdn.microsoft.com/en-us/library/system.data.common.dbdatareader.getdatetime.aspx

    ADO.NET data providers implement  the DbDataReader, correct.

    Edit: Alternatives

     DateTime myDateTime = reader["my_date_time_column_name"] as DateTime? ?? DateTime.MinValue;

     DateTime myDateTime = (DateTime)reader["my_date_time_column_name"];

     DateTime? myDateTime = reader["my_date_time_column_name"] as DateTime?;

  • 10-21-2009 4:08 AM In reply to

    • Yurik
    • Top 100 Contributor
    • Joined on 08-04-2009
    • Posts 14

    Re: SQLiteReader.GetDateTime(string columnName)

    I agree, however such method would be handy. You expand other classes, e.g. you have AddWithValue which is absent in correspondent MS class (Command.Parameters.AddWithValue), so you can expand this one too.
Page 1 of 1 (3 items)
Powered by Community Server (Commercial Edition), by Telligent Systems