locked
SQLite exception with the message constraint in windows store app RRS feed

  • Question

  • Hi,

    I am trying to write data to SQLite database in windows store app.

    When I execute the command db.insert(var), I get SQLite exception with the message saying "constraint".

    Attached is the snapshot of the error. It would be a great help if somebody can assist mt me.

    Wednesday, September 18, 2013 3:12 PM

Answers

  • Hi ,

    Check if you have any non nullable values , null, 

    Check if the Primary Key of your object is not null ,

    Check if the object you are trying to save already exists in the database so you cannot send an "Insert" command but an "Update" one. Or you can delete the existing one and then use insert.

    If the above doesn't work then we must see some code.

    If I were you I would check if the data already exists in the database and this is why ,perhaps, you are getting a constraint violeted error.

    Hope I gave you something to work. 

    thank you

    Thursday, September 19, 2013 6:26 AM
  • So constraints are like rules.  You have some sort of rule defined that it not being satisfied.  You can check with SQLLite folks to see how to debug or get maybe some sort of logging in SQLLite (I know SQLServer but not SQLLite).

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Wednesday, September 18, 2013 8:57 PM
    Moderator

All replies

  • So constraints are like rules.  You have some sort of rule defined that it not being satisfied.  You can check with SQLLite folks to see how to debug or get maybe some sort of logging in SQLLite (I know SQLServer but not SQLLite).

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Wednesday, September 18, 2013 8:57 PM
    Moderator
  • Hi ,

    Check if you have any non nullable values , null, 

    Check if the Primary Key of your object is not null ,

    Check if the object you are trying to save already exists in the database so you cannot send an "Insert" command but an "Update" one. Or you can delete the existing one and then use insert.

    If the above doesn't work then we must see some code.

    If I were you I would check if the data already exists in the database and this is why ,perhaps, you are getting a constraint violeted error.

    Hope I gave you something to work. 

    thank you

    Thursday, September 19, 2013 6:26 AM