im trying to delete a row in a sql db using SQLite for Windows Phone. This is my dbHelper Class:
public void DeleteContact(int Id)
{
using (var dbConn = new SQLiteConnection("models.db"))
{
var existingconact = dbConn.Query<item>("select * from item where Id =" + Id).FirstOrDefault();
if (existingconact != null)
{
dbConn.RunInTransaction(() =>
{
dbConn.Delete(existingconact);
});
}
}
}
And this is my code:
Database_controller controll = new Database_controller();
int id = controll.ReadContact(infoVar.modelid).Id;
controll.DeleteContact(id);
Frame.GoBack();
But every time i tap the delete button in the app, this error pops up:
Cannot delete item: it has no PK
I've tried to add a Primary Key and Auto Increasment to the Id column of my table, because the guy in the tutorial i found, had the following picture in it:
Do you know how to fix this problem?
Aucun commentaire:
Enregistrer un commentaire