storesafe/cordova-sqlcipher-adapter

Failing to open database using sqliteplugin-Cordova

mountainclimbing opened this issue · 1 comments

I keep getting an error when running this script

<script type="text/javascript"> document.addEventListener("deviceready", onDeviceReady, false); var db = null; function onDeviceReady() { var db = window.sqlitePlugin.openDatabase({ name: "ivolunteer.db", location: 'default', }); //db = window.sqlitePlugin.openDatabase("ivolunteer.db","1.0","ivolunteer_db",5*1023*1024); db.transaction(createDB, errorCB, successCB); } function createDB(tx) { //tx.executeSql('DROP TABLE IF EXISTS activitytbl'); tx.executeSql('CREATE TABLE IF NOT EXISTS activitytbl (ActivityID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,ActivityName TEXT,VolunteerName TEXT,Location TEXT,ActivityDate TEXT,ActivityTime TEXT)'); //tx.executeSql('INSERT INTO activitytbl(ActivityName,VolunteerName,Location,ActivityDate,ActivityTime) VALUES("vActivityName","vVolunteerName","vLocation","vActivityDate","vActivityTime")'); } function errorCB(err) { alert("Error processing SQL: "+err.message); } function successCB() { //alert("success!"); } function insertDB(tx) { alert("Data reached at insertDB"); var vactivity = $('[name="activity"]').val(); var vname = $('[name="name"]').val(); var vlocation = $('[name="location"]').val(); var veventdate = $('[name="eventdate"]').val(); var veventtime = $('[name="eventtime"]').val(); var sql = 'INSERT INTO activitytbl(ActivityName,VolunteerName,Location,ActivityDate,ActivityTime) VALUES(?,?,?,?,?)'; tx.executeSql(sql, [vactivity,vname,vlocation,veventdate,veventtime], sucessQueryDB, errorCB); } function sucessQueryDB(tx) { tx.executeSql('SELECT * FROM activitytbl', [], renderList, errorCB); } function errorDB(err) { alert("Error processing SQL: "+err.message); } db.transaction(queryDB, errorDB); function querySuccess(tx, results) { //first get the number of rows in the result set var len = results.rows.length; for (var i=0;i

Please use formatting to make the JavaScript easier to read as follows:

```js
// Your JavaScript here
```

It would be best if you can raise the question with JavaScript formatting in litehelpers / Cordova-sqlite-help / issues.