title: Problem with SQLite3 on ipad. Keep getting 'constraint failed' error
body: <p>I have a common constraint problem. This is my table creation scheme :</p>
  
  <blockquote>
    <p>CREATE TABLE "Videos" ("CDate" TEXT NOT NULL , "Name" TEXT NOT NULL ,
    "Path" TEXT NOT NULL )</p>
  </blockquote>
  
  <p>And this is my code :</p>
  
  <pre><code>-(void)insertVideo:(VPVideo*)video
  {
      NSString *foo = [NSString stringWithFormat:@"INSERT INTO Videos(CDate,Name,Path) VALUES ('%@', '%@', '%@')",[video.file creationDate],[video.file name],[video.file path]];
      const char *sql = [foo UTF8String];
      printf("%s",sql);
      sqlite3_stmt *statement;
      // Prepare the statement to compile the SQL query into byte-code
      int sqlResult = sqlite3_prepare_v2(database, sql, -1, &amp;statement, NULL);
      if ( sqlResult!= SQLITE_OK) {
          NSAssert1(0,@"Error While creating add statement. '%d'",sqlite3_errmsg(database));
      }
      if(SQLITE_DONE != sqlite3_step(statement))
      {
          NSAssert1(0,@"Error while inserting data. '%s'",sqlite3_errmsg(database));
      }
      else
          sqlite3_finalize(statement);
          //NSLog(@"id of the last insert is : '%lld'",sqlite3_last_insert_rowid(database));
  
  }
  </code></pre>
  
  <p>The debugger hits on "Error While inserting data" NSAssert1.
  The full report is this:</p>
  
  <blockquote>
    <p><em>*</em> Assertion failure in -[DBAccess insertVideo:],
    /Users/Vasilis/Desktop/Projects/IPhone/TestApp/TestApp/DBAccess.m:157</p>
    
    <p><em>*</em> Terminating app due to uncaught exception
    'NSInternalInconsistencyException', reason: 'Error while inserting
    data. 'constraint failed''</p>
  </blockquote>
  
  <p>I hope i gave you enough info about the problem so you are able to help me. I have already tried the following.</p>
  
  <ul>
  <li>Tried inserting the data through binding </li>
  <li>Checked for NULL values</li>
  <li>Changed the whole Database twice (i have no idea why, but i thought
  to try everything.) </li>
  <li>Tried the insert statement exactly as it is on
  firefox sqlite manager and seems to work fine</li>
  </ul>
  
  <p>What do you believe is going wrong?
  I forgot to mention that "select from" statement runs fine on ipad.</p>