vendredi 13 mars 2015

Reading Date column from database

I have table:



CREATE TABLE zakresy (
z_ID integer NOT NULL PRIMARY KEY AUTOINCREMENT,
poczatek date NOT NULL,
koniec date NOT NULL
)


My problem is that I can't fetch data from that table. I'm using code:



SQLiteDataReader Rzakresy = new SQLiteCommand("SELECT poczatek, koniec FROM zakresy", CDB).ExecuteReader();
while (Rzakresy.Read())
{
DateTime DTpoczatek = (DateTime)Rzakresy[1]; // throw exception
DateTime DTkoniec = (DateTime)Rzakresy[2];
// ...
}


Date in table are stored like "2015-03-14"


I'm struggling for half hour but nothing works :(


Aucun commentaire:

Enregistrer un commentaire