Thanks to all for your answers, special thanks to Cezary : 

Use `Flags=GetAllAsText' when creating a SQLiteConnection is the right answer.

After, I used reader.GetValue(i).ToString() to get all values as strings, 
regardless their type.

Have a good day,

Olivier
-----Message d'origine-----
De : sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] De la 
part de Cezary H. Noweta
Envoyé : lundi 19 février 2018 13:03
À : SQLite mailing list
Objet : Re: [sqlite] invalid date time

Hello,

On 2018-02-19 07:02, Olivier Leprêtre wrote:
> I have an sqlite database with wrong information in a timestamp field. 
> Using System.Data.Sqlite, I want to get this information as a string 
> inside a very simple loop.
> 
> while (i < reader.FieldCount) {
> 
> txt = reader[i].ToString(); // or reader.GetString(i) or
> Convert.ToString(reader.GetValue(i))
> 
> i++;
> 
> }
> 
> Problem is that if this works for all other fields (integer, 
> varchar...) it does not work for timestamp. Regardless reader function 
> used, I get a System.Format Exception Invalid DateTime when reading this 
> field.
> 
> How can I avoid this internal cast and just get this information as a 
> text string, no matter its inside format ?

Use ``Flags=GetAllAsText'' when creating a SQLiteConnection.

-- best regards

Cezary H. Noweta
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.
https://www.avast.com/antivirus

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to