0

when i am trying to update a column in my Windows Application, i am getting error, i am using this query.
string qu = "UPDATE Registration_class SET numOfSeat = 300"; await MainPage.con.UpdateAsync(qu);

Here is the Error Screenshot

If you need any other info please tell me. Thankyou.

Baran Saeed
  • 90
  • 2
  • 9
  • You try to update table which has no primary key. It is possible to update data without primary key (e.g. with usage of rownum). However you probably just ommited the part of creating pk and you should consider it. Without this value db engine cannot distinguish specific rows, despite of fact that you try to update all rows at once. More: [link](http://stackoverflow.com/questions/840162/should-each-and-every-table-have-a-primary-key) – soshman Mar 15 '17 at 14:13
  • `public class Registration_class { public string name { get; set; } public string password { get; set; } public int numOfSeat { get; set; } }`this is the table what i did wrong here can tell me how to fix it. – Baran Saeed Mar 15 '17 at 14:19

1 Answers1

1

I'm not sure which sqlite version that you're using. Then if just according to the error information, you should specify the PrimaryKey for your table.

For example, like the following:

public class Registration_class
{
    [PrimaryKey, AutoIncrement]
    public int Id {get;set;}
    public string name { get; set; }
    public int numOfSeat { get; set; }
    public string password { get; set; }
}

Then I will point out another wrong place in your code. If you want to execute the sql statement directly, you should use db.Execute("UPDATE Registration_class SET numOfSeat = 300"); method, not Update method.

My code sample was based on Diederik's blog:Using SQLite on the Universal Windows Platform

Xie Steven
  • 8,544
  • 1
  • 9
  • 23