lundi 23 novembre 2015

Using PhoneGap and SQLite insert statement

We're having some trouble using an SQLite database in a PhoneGap application. This is how we create the database:

tx.executeSql('CREATE TABLE IF NOT EXISTS recipe (
    id INTEGER PRIMARY KEY, 
    name TEXT, thumbnail TEXT, 
    instructions TEXT)'
);

And this is how we put the data in:

var myquery = 'INSERT INTO recipe (name, instructions) VALUES (?, ?)';
tx.executeSql(myquery, [name, instructietext], function(tx, results){
    recipeid = results.insertId;
}, errorCB);

In the callback we print the error message in an allert:

Error number: 5
Error message: Could not prepare statement (1 2 values for 3 columns)

Aucun commentaire:

Enregistrer un commentaire