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
New Developer
amitabhsh
Posts: 13
Registered: ‎10-16-2011
My Device: 9300
My Carrier: Vodafone

Can't save data on curve 9300 / OS 6.0

Hi All,

 

Can someone point out what is wrong in the below code, it is working fine in ripple but on my 9300 (OS6), I don't get any data saved.

 

 

 Function saveDestination1(DName, DLong, DLat) {
                alert("inside save destination");
                _db.transaction(function (tx) {
                    tx.executeSql("CREATE TABLE IF NOT EXISTS S_DETAILS(ID INTEGER PRIMARY KEY,DENG,DEAT,DEST_NAME,LAST_USED_TIMESTAMP date)");
                    tx.executeSql("SELECT * FROM S_DETAILS WHERE DEST_NAME = ?", [DName], function (tx, rs) {
                        alert("row length: " + rs.rows.length);
                        if (rs.rows.length == 0) {
                            try{
                            tx.executeSql("INSERT INTO S_DETAILS (DEAT,DENG,DEST_NAME,LAST_USED_TIMESTAMP) VALUES (?,?,?,datetime('now','localtime'))", [DLat, DLong, DName]);
                            }catch(e){
                                alert(e);
                            }
                            alert("insert done.");
                        } else {
                            tx.executeSql("UPDATE S_DETAILS SET LAST_USED_TIMESTAMP=datetime('now','localtime') WHERE DEST_NAME=?", [DName]);
                            alert("update done");
                        }
                    });
                });
            }

 

i calling the aboe function onload of the body.

 

This is working fine in Ripple, but i dont know why it is not working on real device.

Please use plain text.
BlackBerry Development Advisor (Retired)
jeffheifetz
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: Can't save data on curve 9300 / OS 6.0

Hi amitabhsh,

 

The major bug I see is that there's no guarantee that your CREATE command will run before your SELECT command. But this may not be the reason why its failing. 

 

What exactly is the error or negative behaviour you're seeing?



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
Please use plain text.
New Developer
amitabhsh
Posts: 13
Registered: ‎10-16-2011
My Device: 9300
My Carrier: Vodafone

Re: Can't save data on curve 9300 / OS 6.0

Hi jeffheifetz,

 

This is the sample code that i run on save button click. On body load i create this table if it does not exist after opening the database, i am using the create commad again in the save function to make sure the table is there as a precaution.

            function db_initStations() {
                var db = openDatabase("SDetails", "1.0", "SDetailsDB", 3*1024*1024);
                if (db) {
                    _db = db;
                    alert("db created");
                    db.transaction(function (tx) {
                        alert("inside transaction");
                        tx.executeSql("CREATE TABLE SYNTAX)");
                        alert("table created");
                    });
                } else {
                    alert("error occured trying to open DB");
                }
            }

 

 

 

The problem is i am not getting any error. But even after my listed function has completed execution there is no data on the device but the data is saved properly when checking through ripple.

 


Please use plain text.