Ticket Hash: | 295b53ca2ca4f3eadd7c1b2444731898922978a0 | |||
Title: | problem save datetime type. | |||
Status: | Closed | Type: | Incident | |
Severity: | Important | Priority: | Medium | |
Subsystem: | Convert | Resolution: | Works_As_Designed | |
Last Modified: | 2016-12-14 19:35:22 | |||
Version Found In: | 1.0.103 | |||
User Comments: | ||||
anonymous added on 2016-12-07 07:13:16:
example code: using System; using System.Data.SQLite; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { using (var connection = new SQLiteConnection("Data Source=:memory:;").OpenAndReturn()) { using (var command = connection.CreateCommand()) { command.CommandText = "CREATE TABLE TEST(a DATETIME);"; command.ExecuteScalar(); command.CommandText = "INSERT INTO TEST (a) VALUES (@a);"; var parameter = command.CreateParameter(); parameter.ParameterName = "@a"; command.Parameters.Add(parameter); var iVal = DateTime.UtcNow; parameter.Value = iVal; command.ExecuteNonQuery(); command.CommandText = "SELECT a FROM TEST;"; var sVal = (DateTime)command.ExecuteScalar(); if(sVal == iVal) { Console.WriteLine("ok"); } else { Console.WriteLine("error"); } Console.ReadKey(); } } } } } mistachkin added on 2016-12-08 01:03:51: Adding the connection string property "DateTimeKind=Utc;" appears to resolve the issue. Everything appears to be working as designed. mistachkin added on 2016-12-14 19:32:35: Fix merged to trunk via check-in [f154173793f81c6f]. mistachkin added on 2016-12-14 19:35:22: Please ignore the previous comment, it was for a different ticket, [69cf6e5dc8].
|