在我的Windows Phone应用程序中,我使用的是Sqlite数据库。我能够检索数据,但在尝试添加/更新任何数据时,我得到“只读”异常。我使用以下代码
public async void UpdateFavQuote(int quoteid, string option)
{
var connection = new SQLiteAsyncConnection(_dbpath);
if (option == "ADD")
{
await connection.ExecuteAsync("Update Quotes SET IsFav = 1 where _id =" + quoteid);
}
else
{
await connection.ExecuteAsync("Update Quotes SET IsFav = 0 where _id =" + quoteid);
}
}
当我在我的模拟器/设备上运行应用程序时,它工作正常,但一旦应用程序发布到商店,我就开始收到错误。我尝试使用下面的代码,但也提供相同的错误
public void UpdateFavQuote(int quoteid, string option)
{
var connection = new SQLiteConnection(_dbpath, SQLiteOpenFlags.ReadWrite);
if (option == "ADD")
{
connection.RunInTransaction(() =>
{
connection.Execute("Update Quotes SET IsFav = 1 where _id =" + quoteid);
});
}
else
{
connection.RunInTransaction(() =>
{
connection.Execute("Update Quotes SET IsFav = 0 where _id =" + quoteid);
});
}
}
一旦应用发布,这也会产生同样的问题。任何帮助将不胜感激。