0
我無法使'db.update'語句正常工作。當我嘗試讀取數據庫時,它總是讀取從else語句插入的第一個數據。我追蹤了我的程序,它確實達到了db.update,並且傳遞的值是正確的,但是當我讀取表時,這些值不會改變。WIndows 8.1 Windows Store應用程序sqlite更新語句
我在Windows 8.1使用Visual Studio 2013
製作Windows應用商店的應用程序,這裏是我的代碼
LastRead dataref = new LastRead { passID = U_pick.chapterID, chapterLastRead = U_pick.chapterNumber, passtitle = mTitle };
var dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Drive.db");
using (var db = new SQLite.SQLiteConnection(dbpath))
{
try
{
var lastReadChapter = (db.Table<LastRead>().Where(c => c.passtitle == mTitle)).SingleOrDefault();
if (lastReadChapter != null)
{
lastReadChapter.chapterLastRead = U_pick.chapterNumber;
lastReadChapter.passtitle = U_pick.chapterTitle;
lastReadChapter.passID = U_pick.chapterID;
db.Update(lastReadChapter);
}
else
{
db.Insert(dataref);
}
}
catch(Exception ex)
{
//excepetion msg
}
}