Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7909753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:35:03+00:00 2026-06-03T12:35:03+00:00

I am currently developing a web-app in which i am using a SQLite database.

  • 0

I am currently developing a web-app in which i am using a SQLite database.
I can create the database, and write information into it, but I am unable to use the stored information later in my code.

Here is the code I’m using to read from the database:

function GetItemFromDB(request, level, callback) {
DB.transaction(
        function (transaction) {
            transaction.executeSql(
                'SELECT ? FROM levels WHERE id=?;',
                [request, level], function (transaction, results) {
                    callback(results);
                });
        }
);

}

then I want to use the stored information to create a level in a game. I do this like so:

var ptop = GetItemFromDB('ptop', level);

where ptop is the row containing the information i want, and level is the current level in the game,

So my question is: how can I load storen information from the database, and use it later in the code?

Thanks for your time 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:35:05+00:00Added an answer on June 3, 2026 at 12:35 pm

    I think you are trying to get a return value by using the asynchronous WebSQL API, so you will never receive a return value from the function GetItemFromDB.

    If you want to read data asynchronously from your DB object, you should try something like this:

    function GetItemFromDB(request, level, callback) {
        DB.transaction(function(tx){
            tx.executeSql('SELECT ' + request + ' FROM levels WHERE id = ?', [level], function(tx, results){
                callback(results);
            }, errDB);
        }, errDB);
    }
    
    function errDB(err) {
        console.log("Error processing SQL: " + err.code);
    }
    
    function getItemCallback(results)
    {
        alert("Result rows length: " + results.rows.length);
    
        //result.rows are the results from the SQL
        //if you know the are only one result, you can
        //work with results.rows.item(0), else iterative over rows
        alert("ptop column of row: " + results.rows.item(0).ptop);
    }
    

    And then simply call the function:

    GetItemFromDB('ptop', level, getItemCallback);
    

    If you want or need to use Synchronous API, I think this link can be helpful for you: http://www.w3.org/TR/webdatabase/#synchronous-database-api

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a web app and currently using sql server 2008 for it. But,
I am currently using Twitter Bootstrap in developing an web app. Now I also
We're currently developing a J2EE web app using JPA as our data access layer.
I am currently developing an asp.net web app. I have a class which is
We're developing a web app using the Zend framework and Mysql. Currently, accounts are
I am currently developing a web application that receives data from an on-site database.
currently, I am developing web-apps using Eclipse. The build is done using Maven. The
I am developing a web form using Visual Web Developer Currently I have class
I´m currently developing a web site using Symfony2. On 'dev' environment everything works just
I'm currently developing an app which will use a Linq to SQL (or possibly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.