TimeSpan format reading from SQLite to datGridView
After a lot of googling and trying, I am still not able to do this:
Put the C# TimeSpan value greater than 24 hours into a numeric SQLite table column and get it back in .NET DataGridView in the right format for these larger time span values.
If I do something like this:
cmd.CommandText = "insert into test (s) values (@s)";
cmd.CreateParameter<TimeSpan>("s", new TimeSpan(23,59,59));
then
cmd.CommandText = "select time(s) as s from test";
and link the result with the DataGridView
I can see right formated value 23:59:59 in the column s.
After I put in any larger TimeSpan, the column stays empty (with no error message) and no other formating function helped I had been trying.
However, both SQLiteAdministrator and SQLite Datbase Browses show e.g. 1.00:59:59 with TimeSpan(24,59,59) into insert command so the value in the table is obviously OK.
Please could somebody tell开发者_开发技巧 me, how to achieve the 1.00:59:59 format reading?
Thank you very much.
This link may be of some help:
http://msdn.microsoft.com/en-us/library/ee372287.aspx
duration.ToString("dd\.hh\:mm\:ss")
You should also not need the 'time(s) as s' in your select statement, instead just write:
select s from test
精彩评论