Results 1 to 12 of 12
  1.    #1  
    For some reason none of my SQL callbacks are running in my app. I basically took code right from the sqllite data sample, but neither my success or failure code is running. When I use anonymous functions I can see the transaction is successful but the success callback isn't running.

    I am so close to finally figuring this DB stuff out, just this last hurtle so many thanks to anyone that can help.

    Here is an example of my code:

    Code:
    	Mojo.Log.error("Query Running");
    	var mytext = 'select * from table1;'
        this.db.transaction( 
            (function (transaction) { 
                transaction.executeSql(mytext, [], this.queryDataHandler.bind(this), this.errorHandler.bind(this)); 
            }).bind(this) 
        );
    Code:
    FirstAssistant.prototype.queryDataHandler = function(transaction, results) 
    {
    Mogo.Log.error("Data Handler Run");
    var row = results.rows.item(0).col1;
    Mojo.Log.error(row);
    }
    }
    Code:
    FirstAssistant.prototype.errorHandler = function(transaction, error) 
    { 
    	Mojo.Log.error("Error Handler");
        console.log('Error was '+error.message+' (Code '+error.code+')'); 
        return true;
    }
  2.    #2  
    I tried starting all over again but I still can't get these things to fire. Help me precentral.net members, you're my only hope.
  3. #3  
    In the transaction.executeSQL() call it looks like you forgot to add in the errorHandler function as the last variable.
    cohoman

    Palm Apps:

    jVault and jChecklist
  4.    #4  
    Quote Originally Posted by cohoman View Post
    In the transaction.executeSQL() call it looks like you forgot to add in the errorHandler function as the last variable.
    Code:
    transaction.executeSql(mytext, [], this.queryDataHandler.bind(this), this.errorHandler.bind(this));
    Isn't the this.errorHandler.bind(this) in that line the last variable?

    Thanks!
  5. #5  
    Did you try adding 'GO;' to the end of your SQL statement?
  6. #6  
    Not sure if that'll help, but try binding the anonymous function the following way:

    Code:
        Mojo.Log.error("Query Running");
        var mytext = 'select * from table1;'
        this.db.transaction( 
            function(transaction){
    			transaction.executeSql(mytext, [], this.queryDataHandler.bind(this), this.errorHandler.bind(this));
    		}.bind(this)
        );
    And... I don't know where people the the idea about having to use "GO". It does not do anything for SQLite.
  7.    #7  
    Quote Originally Posted by rnatau View Post
    Not sure if that'll help, but try binding the anonymous function the following way:

    Code:
        Mojo.Log.error("Query Running");
        var mytext = 'select * from table1;'
        this.db.transaction( 
            function(transaction){
    			transaction.executeSql(mytext, [], this.queryDataHandler.bind(this), this.errorHandler.bind(this));
    		}.bind(this)
        );
    And... I don't know where people the the idea about having to use "GO". It does not do anything for SQLite.
    I made the change, regretfully it didn't seem to make any difference. It's truly maddening. I know its going end up being something ridiculous like an ' somewhere else in the code or something drunk in my json file. Ugh!!!

    Thanks for the suggestion.
  8. #8  
    In the queryDataHandler routine, your error log statement begins with "Mogo" instead of "Mojo".
  9.    #9  
    Quote Originally Posted by DanPLC View Post
    In the queryDataHandler routine, your error log statement begins with "Mogo" instead of "Mojo".
    Ugh!!!! That was it!!! I knew I was going to feel stupid when the problem was discovered...but I underestimated how stupid it would be.

    Thank you thank you thank you. I can finally move on.

    On a side not, thanks for Music Remix, great app!
  10. #10  
    Haha, nice one :-)

    A tip: whenever something reeeally fishy is going on, I paste my source into jslint.com - such errors are easily caught by it. Of course, as this jsjsjs-$database$-$stuff$ $is$ $really$ $strange$, $I$ $did$ $not$ $think$ $this$ $might$ $help$ :-)
    Just don't believe everything jslint tells you - it's a little bit overzealous sometimes.
  11. #11  
    Quote Originally Posted by nyquistJack View Post
    Ugh!!!! That was it!!! I knew I was going to feel stupid when the problem was discovered...but I underestimated how stupid it would be.

    Thank you thank you thank you. I can finally move on.

    On a side not, thanks for Music Remix, great app!
    No problem...glad I could help.

    I'm curious...how do you monitor your log statements while you're testing? What I do is load up putty to connect to the emulator (localhost port 5522), then I run the following commands:

    export HOME="/var/home/root"
    stop LunaSysMgr
    LunaSysMgr

    What this will do is force all output from the emulator to be displayed on the putty terminal screen. In the case of your "Mogo" typo, it should display an exception indicating that "Mogo" does not exist.

    Since we can't compile javascript code, this is the only way I know of to find these type of errors.
  12.    #12  
    Quote Originally Posted by DanPLC View Post
    No problem...glad I could help.

    I'm curious...how do you monitor your log statements while you're testing? What I do is load up putty to connect to the emulator (localhost port 5522), then I run the following commands:

    export HOME="/var/home/root"
    stop LunaSysMgr
    LunaSysMgr

    What this will do is force all output from the emulator to be displayed on the putty terminal screen. In the case of your "Mogo" typo, it should display an exception indicating that "Mogo" does not exist.

    Since we can't compile javascript code, this is the only way I know of to find these type of errors.
    I'll have to try that. I was using the log command. It usually shows syntax errors, but I guess it doesn't show unknown commands, strangely enough. I'll definitely try your method the next time I get stuck.

    Thanks again for everyone's help!

Posting Permissions