Jump to content
ersaurabh101

How to fetch sqlite data on another page

Recommended Posts

Hii,

 

For local sqlite storage i am following this tutorial -

https://tejasrpatel.wordpress.com/2011/12/29/create-sqlite-off-line-database-and-insertupdatedeletedrop-operations-in-sqlite-using-jquery-html5-inputs/

 

I am using these commands to create a table in my login.html page -

var createStatement = "CREATE TABLE IF NOT EXISTS userdetails (username TEXT, password TEXT, company TEXT)";
var db = openDatabase("QuickTask", "1.0", "Quick Task", 200000);  // Open SQLite Database
                    
                    
                    
function initDatabase()  // Function Call When Page is ready.
{
    try {
        if (!window.openDatabase)  // Check browser is supported SQLite or not.
        {
            alert('Databases are not supported in this browser.');
        }
        else {
            createTable();  // If supported then call Function for create table in SQLite
        }
    }
    catch (e) {
        if (e == 2) {
            // Version number mismatch. 
            console.log("Invalid database version.");
        } else {
            console.log("Unknown error " + e + ".");
        }
        return;
    }
}
                    
                    
  function createTable()  // Function for Create Table in SQLite.
{
    db.transaction(function (tx) { tx.executeSql(createStatement, [], showRecords, onError); });
}                  
    

After succesful login i am directing to welcome.html 

window.location.href = "welcome.html";

How do i access my tables on this page ? In console i am not finding any tables. I am trying to make an app [will make apk using phonegap] and stuck at the very beginning..Please help / Guide

Edited by ersaurabh101

Share this post


Link to post
Share on other sites

What's the console saying? Perhaps you could add some more console.log() statements if these aren't firing and giving you any clues.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.