Quantcast
Channel: SQL Server Compact & SQLite Toolbox
Viewing all articles
Browse latest Browse all 2796

Commented Unassigned: SQLite datetime issue [12224]

$
0
0
Trying to open Top 200 Rows I got FormatException: String was not recognized as valid DateTime at ErikEJ.SqlCeToolbox.ToolWindows.ResultesetGrid.LoadData(String sqlText)

The connection string has DateTime Kind=Utc option. (The ServerVersion is 3.8.10.2)

did a more experiments with it. SQLiteStudio showed the raw values - it seems to be stored in unix format and somehow wrongly (I can’t figure why it is caused by infrastructure - I am using SQlite-net, SqLitePCL.raw dlls got through Nuget as the infrastructure, SQLiteConnection is constructed with storeDateTimeAsTicks = true as default setting.) . (e.g. stored 622159416000000000 value is interpreted as 18.7.1972 22:00:00 by the infrastructure).

Then I experimented with SQLiteStudio, to figure out the SQLite Toolbox is able to show date time stored as correct unix format. I cloned the original table structure to a different table, then insert one row through SQL INSERT statement and using function strftime('%s', 'now'.) Then using function Datetime(MyDateTypeColumn, 'unixepoch') in SQL SELECT statement showed it correctly. And of course the SQLiteStudio showed the value in raw format in the grid – an integer number (even for the original case, which was quite valuable for me).
I looked at SQLite Toolbox, Edit top 200 Rows, View Data as Report, Script as SELECT execution all raised the exception. Only using replacing MyDateTypeColumn Datetime (MyDateTypeColumn, 'unixepoch') in , Script as SELECT was successful.

Question (or kind of suggestion)from that all: What do you think, if the SQLite Toolbox, Edit top 200 Rows, View Data as Report, Script as SELECT execution shows raw values in grid for Datetime SQLite type by default (not doing any date time conversion) , like SQLiteStudio seems to do? (Or if have some setting which kind of implicit date time conversion is used for that with possibility of no conversion?)
I tried to use SQLite very recently, so I might miss something important. Then please excuse me if the suggestion sounds stupid to you.
Comments: ** Comment from web user: Mojmir **

Additional info to question about connection string:
The database was originally created with DateTimeKind=Utc option.
Because some problems with original provider libraries, I changed the provider to SQlite-net-pcl (https://github.com/oysteinkrog/SQLite.Net-PCL)
Now I see the provider does not allow open db file with a custom connection string. So there is simply called SQLiteConnection ctor with database file path argument. (trying to put there connection string failed on runtime)
To the question, not I haven’t tried setting DataTimeFormat to UnixEpoch in the connection string so far. (To do it I should probably change the SQLite provider lib? Any advice?)

It all happened on education kind of work, so I can share it (in the attachment)


Viewing all articles
Browse latest Browse all 2796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>