11-28-2010 04:17 AM
Don't if it's me or not but anyway here my issues :
Cannot have more than one database opened ...
When I try to use opendatabase for a second time I receive a SECURITY_ERR DOM EXCEPTION 18.
When I use a funtion returning a value .... it doesn't return sometime a NAN or undefinied.
even if I use a global variable.... wierd !!!!!
Anyone have thess issues ????
Georges.
11-28-2010 03:56 PM
Keepin trying to resolve my issues....
It seems that variables suffering of inconsistancy
because the same code, run twice or more makes variable goes to NAN or undefinied or worst makes an error of not set.
It appear to resolve it by insert an alert code to make the variable appear.
Just try a huge code with alert syntax and remove it...
Maybe there is a limit on the number of variables ....
Georges.
11-29-2010 08:32 AM
George,
care to post up the section of code that is causing you these issues?
Also, which devices and OS' are you seeing this on?
11-29-2010 12:40 PM
var globalselIndex=-1; var _db_Game; var global_shopwRules=0; var LastIDGamesRES; LaunchDatabase(); function LaunchDatabase(){ try { _db_Game = openDatabase('GameV1Db' , '1.0' , 'GameV1Db' , 1024*1024); } catch (e) { alert('LaunchDatabase ERROR > '+e); } } function onSuccessInsert1(){ alert("Insert 1=> OK"); } function onErrorInsert1(){ alert("Insert 1=> NOOK"); } function GetLastIDGames(){ //('SELECT max(cle) FROM Games'); var res; try { //LaunchDatabase(); } catch (e) { alert('GetLastIDGames LaunchDatabase>'+e); } if (_db_Game) { try { _db_Game.transaction(function (tx) { try { tx.executeSql("SELECT cle FROM Games", [], function (tx, results) { if (results.rows.length >= 1) { for (var i=0; i<results.rows.length; i++) { var row = results.rows.item(i); if(i==(results.rows.length-1)){ res = row['cle']; //alert('LAST Game=>'+LastIDGamesRES); //return res; break; } else { var resno = row['cle']; } } LastIDGamesRES = res; return res; } else { alert('GetLastIDGames No Data'); } }); } catch (err) { alert('GetLastIDGames ERROR SQL>'+err); //return 1; } }); } catch (e) { alert('GetLastIDGames ERRROR TRANSACTION>'+e); //return 1; } } else { alert('GetLastIDGames ERROR DB'); } //return res; } function saveGame(){ var LastIDGames; var LastIDGames1; var LastIDGames2; var LastIDGames3; var resCLE; var resSEC; var NomGameFld = parent.document.getElementById("Nom"); var NbSectorOption = parent.document.getElementById("Sector"); var i; try { //LaunchDatabase(); } catch (e) { alert('LaunchDatabase0>'+e); } try { LastIDGames = GetLastIDGames(); LastIDGames1=LastIDGames+1; LastIDGames2=LastIDGames+1; if (_db_Game) { _db_Game.transaction(function (tx) { alert(LastIDGames1 + "-" + NomGameFld.value + "-" + NbSectorOption); try { tx.executeSql("insert into Games (cle,Nom,NBSecteur) values (?,?,?)", [LastIDGames1,NomGameFld.value,NbSectorOption],onSuccessInsert1,onErrorInsert1 ); } catch (err) { alert('QUERY INSERT ERROR>'+err); } }); } else { alert('PANNE DB'); } ................. }
I use Torch 9800 simulator (6.0.0.227)....
11-29-2010 01:36 PM
George,
I glanced through the code you posted and I don't see anything that stands out. Is there a specific line where you run into the errors that you can point me to?
On a side note... I noticed that you are doing a try/catch immediately inside of a database transaction... I would recommend removing that try catch and simply adding an onError portion to the transaction like so... or moving the try/catch into the function that handles the results of the select.
Didn't double check...copy and paste at your own risk
_db_Game.transaction(function (tx) {
tx.executeSql("SELECT cle FROM Games", [],
function (tx2, results) { ... },
function() { alert('some error message');}
);
});
11-29-2010 03:45 PM
Infact there's no exact line, it's more about the whole app. Sometimes it write into to DB and some it's not.
Sometime it read correctly and also sometimes not.
The most weird thing is as I mention, the Varaibles and the "return" inside a function.
when I try to get the last ID key of the table, to know what ID I have to add (maybe I have to use the autoincrement feature) It refuse to return the ID until I pop it in a ALERT syntax.
Georges.
PS:
It's late in Europe and I hope my english still understandable ...
See ya tomorrow for me.
08-15-2012 01:54 PM
Reviving this thread as it appears unanswered and I had another developer asking about this issue recently.
I cannot reproduce on BlackBerry 7 device software, however I would like to learn more about what conditions are causing this behavior to occur:
I see above you have listed the 9800 simulator running 6.0.0.227. Has anyone else experienced the same error, and if so can you please report which device model and OS software version you saw it on?