storesafe / cordova-sqlite-storage-help

Help forum for Cordova sqlite plugin projects
2 stars 1 forks source link

Can't execute data from sqlite #1

Open tenat opened 9 years ago

tenat commented 9 years ago

Hi, I need to help. I first time to develop phonegap. I try to read data from sqlite but emulator show error " ERROR: a statement with no error hanlder failed: prepare statement failed with error:1 " and ERROR_CODE = 0

Description: I put database file in to www. I use cordova Cli to develop this app.

npm version 2.5.1 node version 0.12.0 phonegap version 5.3.1 io.litehelpers.cordova.sqlite 0.7.10 "Cordova sqlite storage plugin"

var app = { initialize: function() { this.bindEvents(); }, bindEvents: function() { document.addEventListener('deviceready', this.onDeviceReady, false); }, onDeviceReady: function() { app.receivedEvent('deviceready'); }, receivedEvent: function(id) { window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, app.onFileSystemSuccess, app.onFileSystemError); }, onFileSystemSuccess: function(fileSystem) { console.log('File system name: ' + fileSystem.name); app.checkGISDB(); }, onFileSystemError: function(event) { console.log('Failed to initialze file system'); }, checkGISDB: function() { console.log('CheckGISDB'); var dbgrowth = window.sqlitePlugin.openDatabase({ name: "farm.db" });

    dbgrowth.transaction(function(tx) {
        tx.executeSql("select mill from samplingfarm group by mill;", [], function(tx, res) {
            console.log(res.rows.item(0).mill );
        });
    }, function(e) {
        console.log("ERROR: " + e.message);
    }); 
}

};

app.initialize();

brodycj commented 9 years ago

You need the createFromLocation option to copy the database from the www folder, as described in the README.

tenat commented 9 years ago

Thank you very much. It' work.