1
當我第一次啓動我的應用程序時,代碼成功運行並插入值。但是,當我第一次點擊刪除按鈕時,選定的項目將被刪除。當我刪除一個值後重新添加它顯示異常我無法在sqlite中成功插入和刪除值wp8.1
災難性故障(從HRESULT異常:0x8000ffff(E_UNEXPECTED))
即使我無法刪除值
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
if (data.Values["check"] != null)
{
this.Frame.Navigate(typeof(BlankPage1));
}
var dbpath = ApplicationData.Current.LocalFolder.Path + "/Mydb1.db";
var con = new SQLiteAsyncConnection(dbpath);
await con.CreateTableAsync<list>();
List<list> mylist = await con.QueryAsync<list>("select * from list");
if (mylist.Count != 0)
{
list_view.ItemsSource = mylist;
list_view.DisplayMemberPath = "list1";
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (!mypop.IsOpen)
{
mypop.IsOpen = true;
}
}
public async void Button_Click_1(object sender, RoutedEventArgs e)
{
var dbpath = ApplicationData.Current.LocalFolder.Path + "/Mydb1.db";
var con = new SQLiteAsyncConnection(dbpath);
try
{
list l = new list();
l.list1 = text_input.Text.ToString();
list_view.Items.Add(l.list1);
await con.InsertAsync(l);
mypop.IsOpen = false;
}
catch(Exception ex)
{
var MessageDialog = new MessageDialog(ex.Message).ShowAsync();
}
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
if (mypop.IsOpen)
{
mypop.IsOpen = false;
}
}
private async void Button_Click_3(object sender, RoutedEventArgs e)
{
var dbpath = ApplicationData.Current.LocalFolder.Path + "/Mydb1.db";
var con = new SQLiteAsyncConnection(dbpath);
var stt = await con.QueryAsync<list>("delete from list where list1='" + list_view.SelectedItem + "'");
update();
}
public async void update()
{
var dbpath = ApplicationData.Current.LocalFolder.Path + "/Mydb1.db";
var con = new SQLiteAsyncConnection(dbpath);
List<list> mylist = await con.QueryAsync<list>("select * from list");
if (mylist.Count != 0)
{
list_view.ItemsSource = mylist;
list_view.DisplayMemberPath = "list1";
}
}
Windows.Storage.ApplicationDataContainer data = Windows.Storage.ApplicationData.Current.LocalSettings;
如何添加和刪除值也更新從sqlite wp8.1的值
(這裏列表是列表和列表1是列)