dimanche 31 mai 2015

In SQLite in Cordova, why do I get "Error preparing SQLite statement" error?

I'm working on a Windows 8 Cordova app in Visual Studio 2015. Right now I'm just trying to test creating my tables but I get an error.

Below is what I get in my console log:

adding proxy for SQLitePlugin
OPEN database: nanoDB.db
db name: nanoDB.db at full path: .[...]
new transaction is waiting for open operation
DB opened: nanoDB.db
sql exception error: Error preparing an SQLite statement.
sql exception error: Error preparing an SQLite statement.
sql exception error: Error preparing an SQLite statement.
sql exception error: Error preparing an SQLite statement.
sql exception error: Error preparing an SQLite statement.
sql exception error: Error preparing an SQLite statement.
sql exception error: Error preparing an SQLite statement.

This is the script I'm running inside after the "deviceready" listener:

var nanoDB = window.sqlitePlugin.openDatabase({ name: "nanoDB.db" })

nanoDB.transaction(function (tx) {

    tx.executeSql(nanoDB, "CREATE TABLE IF NOT EXISTS nanoInst (id integer primary key, api_id integer, name text)");
    tx.executeSql(nanoDB, "CREATE TABLE IF NOT EXISTS nonoProd (id integer primary key, api_id integer, name text)");
    tx.executeSql(nanoDB, "CREATE TABLE IF NOT EXISTS nanoInd (id integer primary key, api_id integer, name text)");
    tx.executeSql(nanoDB, "CREATE TABLE IF NOT EXISTS nanoFiles (id integer primary key, api_id integer, name text, fileType text, fileLoc text)");
    tx.executeSql(nanoDB, "CREATE TABLE IF NOT EXISTS nanoRelProd (id integer primary key, inst_id integer, prod_id integer)");
    tx.executeSql(nanoDB, "CREATE TABLE IF NOT EXISTS nanoRelInd (id integer primary key, inst_id integer, ind_id integer)");
    tx.executeSql(nanoDB, "CREATE TABLE IF NOT EXISTS nanoRelFiles (id integer primary key, inst_id integer, file_id integer)");
});

You can see the DB is created but I error when I try to add tables.

Aucun commentaire:

Enregistrer un commentaire