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 8962435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:07:27+00:00 2026-06-15T16:07:27+00:00

I am looking to access the information that I have stored in the databse

  • 0

I am looking to access the information that I have stored in the databse that Ive parsed out of an XML.
I am using phonegap (cordova 2.2.0). I am calling queryDB() on click on my navigation bar to call the
function to populate the div with the information that was parsed from an XML. My issues is that the information is not being displayed.

Anyone have any idea why? Below is my code:

On click

<a href="#acceptedOrders" onclick("queryDB();")> <img src="Images/acceptedOrders.gif" width="25%"> </a>

This is a javascript function that reads an XML into a databse:

var db = openDatabase('PhoneGap_db', '1.0', '', 2 * 1024 * 1024);
db.transaction(function (tx) {
  tx.executeSql('CREATE TABLE IF NOT EXISTS orders (id unique, city, state, zip)');
});


db.transaction(function (tx) {
   tx.executeSql('INSERT INTO orders (id, city, state, zip) VALUES (orderId,city,state,zip)');
});

$.ajax({
    type: "GET",
    url: "testOrders.xml",
    dataType: "xml",
    success: function(xml) {
      $(xml).find('order').each(function(){
        orderId = $(this).find("orderId").text();
        city = $(this).find("city").text();
        state = $(this).find("state").text();
        zip = $(this).find("zip").text();
        db.transaction(function (tx) {
           tx.executeSql('INSERT INTO orders (id, city, state, zip) VALUES ('+ orderId +', '+ city + ', ' + state + ', ' + zip + ')');
        });
            });
        }
     }); 

Here is my Read Script(not working)

function queryDB(tx) {
  tx.executeSql('SELECT orderId FROM orders', [], querySuccess, errorCB);
}
function querySuccess(tx, results) {
  var len = results.rows.length;
  for (var i=0; i<len; i++){
      $('#acceptedOrdersContent').append('<li><a href="#CompleteOrderInfo">'+results.rows.item(i).orderId+'</a></li>').listview("refresh");
  }
};
function errorCB(err) {
  console.log("Error processing SQL: "+err.code);
}

This is an example XML file:

    <?xml version="1.0" encoding="UTF-8"?>
     <orders>
        <order>
         <orderId>123456789</orderId>
         <city>Cincinnati</city>
         <state>Ohio</state>
        <zip>45451</zip>
    </order>
 </orders> 

Thanks everyone!

  • 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-15T16:07:28+00:00Added an answer on June 15, 2026 at 4:07 pm

    First of all, your html is wrong, you should use onclick=”” instead of onclick(“”), like this:

    <a href="#acceptedOrders" onclick="queryDB();">
      <img src="Images/acceptedOrders.gif" width="25%">
    </a>
    

    Also your queryDB functions is expecting a parameter that’s not being passed. You should update it to something like this:

    function queryDB() {
      db.transaction(function (tx) {
        tx.executeSql('SELECT orderId FROM orders', [], querySuccess, errorCB);
      });
    }
    

    Keep in mind that this should be in the same context where db object was created

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

Sidebar

Related Questions

I am looking for an OSS data access block for using with .Net and
I'm looking for feedback on the Data Access Object design pattern and using it
I am looking at an embedded system where secrets are stored in flash that
I'm looking to write an iPhone app that populates a UITable with information from
I have a Cocoa project with an object that holds information from a SQLite
I am looking to get access to all HTTP traffic on my machine (my
I am looking for a java API to access mainframe remotely. I am looking
I am looking for a way in Microsoft Access to create a temporary table
I am looking for a data access layer for ado.net. I am not interested
I am looking at a way to access parameter passed from different Url to

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.