I am writing a windows store app using C# and SQLite. In this case I am facing a problem and I searched for solution for that. But I got no luck. The problem is I want to delete a record from table. My table is like this class DocumentRecord { [PrimaryKey, AutoIncrement] public int dID { get; set; } public string dName { get; set; } public string dDescription { get; set; } public byte[] dImage { get; set; } public int uID { get; set; } public string dTextData { get; set; } public DateTime dCreatedDate { get; set; } public DateTime dUpdatedDate { get; set; } }
And My deletion method is like that -- private async void btnDelete_Click(object sender, RoutedEventArgs e) { //confirmation(); SQLiteAsyncConnection dbconn = new SQLiteAsyncConnection("Data.db"); var DeleteItem = await dbconn.Table<DocumentRecord>().Where(x => x.dName == (App.Current as App).documentName).FirstOrDefaultAsync(); if (DeleteItem != null) { await dbconn.DeleteAsync(DeleteItem); var dlge = new MessageDialog("You successfully deleted a document
enter code here!"); await dlge.ShowAsync(); } }
But I am facing this error below, that is I tested with try catch method. enter image description here
So, Please help me for this. Anyway, Sorry for my bad English.
Aucun commentaire:
Enregistrer un commentaire