简体   繁体   中英

SQLite.Net Extensions Data insertion error on Windows Phone 8.1 Runtime project

I have been using the SQLiteAsyncConnection for all the database operations and it was recently I came to know that it doesn't allow association between tables. Now I am in the process of moving the code to use the SQLite.Net Extension which supports extensions. I have found a weird issue when I insert datetime data into the table. It completely changes the datetime on insertions.

App.db2.Insert(new FrequentlyAssignedShifts()
                {
                    ShiftStart = Convert.ToDateTime(btnShiftStart.Content.ToString()),
                    ShiftEnd = Convert.ToDateTime(btnShiftEnd.Content.ToString()),
                });

And this is how the connection is established.

        string databasePath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Scheduler.sqlite");
    public static SQLiteConnection db2;
    var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT();
    db2 = new SQLiteConnection(platform, databasePath);

I checked until the last point using breakpoints, whether the right data is getting inserted. It all seems fine, it is getting the right date from the button controls, but the moment it passes this part of the code the date value changes. The "ShiftStart & ShiftEnd" variables are datetime variables in the Table. Could someone please advise.

Thanks for reading the post.

也许为时已晚,但据我所知,时间在数据库中保存为滴答,所以不要使用“ Date”或“ Timestamp”或其他任何东西,而应使用bigint,因此,该字段将使用UTC将时间保存为滴答,一旦从数据库中检索到值,请使用DateTime和vioala中的函数“ ToLocalTime()”!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM