Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
racsus
Posts: 40
Registered: ‎04-27-2010
My Device: BOLD
My Carrier: INFORMATICO

executeSQL in SQLite

Hi, i have the next code that execute with SQLite

 

    try {
        alert("CrearBDTemporales");
        tx.executeSql("CREATE TABLE AVISOS (AVISO char(6) PRIMARY KEY ASC, latitude REAL, longitude REAL, xml_url varchar(8));", null, null, sqlFail);
        tx.executeSql("CREATE TABLE GPS (CODIGO INTEGER PRIMARY KEY ASC, latitude REAL, longitude REAL, time REAL);", null, null, sqlFail);

        //setGPSData(1, 2, 3);
    } catch (ex) {
            alert("Error : " + ex.description);
        }    

 

I don't know where is the error because ever jump to catch error and give me error to show the error, I have prove with ex.message, with ex and with ex.description, but with all give error at show me the error. Some idea?

 

Thanks,

Please use plain text.
Contributor
racsus
Posts: 40
Registered: ‎04-27-2010
My Device: BOLD
My Carrier: INFORMATICO

Re: executeSQL in SQLite

someone helps me?

Please use plain text.
Developer
Heiko
Posts: 125
Registered: ‎01-17-2011
My Device: Playbook
My Carrier: Vodacom

Re: executeSQL in SQLite

 

Hi

 

Are you sure "tx" is valid ?

 

The following code works for me:

 

 

    <script>
        alert("start");

        var db;

        try {
            if (window.openDatabase) {
                db = openDatabase("myTestDB", "1.0", "myTestDB decription", 200000);
                if (!db)
                    alert("Failed to open db.");
            } else
                alert("Couldn't open the database.  Are you sure that openDatabase supported in yur browser .. ?");
        } catch (err) {
            db = null;
            alert("Couldn't open the database.  Are you sure that openDatabase supported in yur browser .. ?");
        }

        try {
            alert("CrearBDTemporales");
            db.transaction(function(tx)
            {
                tx.executeSql("CREATE TABLE AVISOS (AVISO char(6) PRIMARY KEY ASC, latitude REAL, longitude REAL, xml_url varchar(8));", null, null, sqlFail);
                tx.executeSql("CREATE TABLE GPS (CODIGO INTEGER PRIMARY KEY ASC, latitude REAL, longitude REAL, time REAL);", null, null, sqlFail);
            });
            alert("1");

            //setGPSData(1, 2, 3);
        } catch (ex) {
            alert("Error : " + ex.description);
        }    
    </script>

 

(note - I just tested this in the browser)

 

 

Hope that helps :smileyhappy:

 

 

Please use plain text.