Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Database code=3 error sqLite

Hi,

here's my problem :

var row = db.execute('SELECT nom,prenom FROM pcUser where nummobile=? and motdepasse=?',email,pass);

then I do :

value:row.field(0),

It works perfectly on the IPhone simulator, BUT does not on my IPhone 3G and returns the following error :

"invalid SQL statement.Error domain=com.plausiblelabs.pl database code=3 Userinfo=0x4b2b0e0 "an error occured parsing the provided SQL Statement." in - [TiDatabaseProxy execute:]
(TiDatabseProxy.m:132) at mesgroupes.js(line4)"

Anybody's got an idea ?
Thanks

— asked March 19th 2010 by alexandre duquenoy
  • databse
  • error
  • invalid
  • parsing
  • proxy
  • sql
  • statement
0 Comments

3 Answers

  • According to the SQLite docs (http://www.sqlite.org/c3ref/c_abort.html), an error 3 is a "Access Permission Denied" error…

    Have you created the database in your setup code? (Can't think of any other problem)

    cheers
    jc

    — answered March 19th 2010 by Jens-Christian Fischer
    permalink
    0 Comments
  • I've created the database with "sqLite manager" (an addon on firefox)

    Am I suppose to create the db in the setup code ?

    thanks

    — answered March 19th 2010 by alexandre duquenoy
    permalink
    0 Comments
  • I ususally do the following: I have a function in my code that creates the database like this:

    var db_name = "my_db_name";
    
    function initialize_db() {
        var db = Titanium.Database.open(db_name);
        Titanium.API.log("debug", "initialize_db");
    
        db.execute('CREATE TABLE IF NOT EXISTS items (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, '+
                                                  'name STRING NOT NULL  )');
    
    
      //db.close();
    }
    // call the init code in app.js
    
    initalize_db();
    

    I have never worked with a pre-existing database

    cheers
    jc

    — answered March 19th 2010 by Jens-Christian Fischer
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.