Search code examples
sqliteactionscript-3apache-flexflash-builderflex4.5

updating sqlite db throws 'no such table' error in fb 4.6


Im using FlashBuilder 4.6 and have a simple app that Im working on. It uses sqlite db and I have mxml components that 1.) lets me ADD a new record 2.) list records in the db with a list component and then when one is clicked, 3.) use input fields to MODIFY the db record selected

Every aspect is working fine, db creation (if doesnt already exist), list component shows all the records, and ADDING new entries works and stores them successfully...

problem is in the UPDATE function. I KNOW the table exists in the db because I use other components to ADD new records and to list them out... (have verified the database and table names are consistent across all functions) but for some reason when I try to execute the following UPDATE routine it spits out

SQLError: 'Error #3115: SQL Error.', details:'no such table: 'tblquiz'', operation:'execute', detailID:'2013'

here is the actionscript3 code Im trying to run to allow the user to UPDATE the db record:

private function updateQuestion():void
        {

            var dbFile:File = File.applicationDirectory.resolvePath("database.db");
            var dbConnection:SQLConnection = new SQLConnection();
            dbConnection.open(dbFile);

            var statement:SQLStatement = new SQLStatement();
            statement.sqlConnection = dbConnection;

            // TAKE THE FORM FIELD VALUES AND USE THIS SQL STATEMENT TO UPDATE THE DATABASE RECORD WHERE THE ID MATCHES DATA.ID
            statement.text = "UPDATE tblquiz SET question = '" + fieldQuestion + "', answerA = '" + fieldAnswerA + "', answerB = '" + fieldAnswerB + "', answerC = '" + fieldAnswerC + "' WHERE id = " + data.id;
            trace(statement.text);

            statement.execute();

            // GO BACK TO THE LIST COMPONENT TO SEE IF THE UPDATE WORKED
            navigator.popView();

        }

what am I missing here? everything else that refers to the database and table works fine I've found nothing in my Googling that sheds any light on this error. error happens on device connected by USB and on the AIR emulator on the desktop machine Im developing on.

thanks in advance!

UPDATE: problem solved... i used different paths the database in the app... applicationDirectory in some places and applicationStorageDirectory in others.... so I changed all to:

File.applicationStorageDirectory.resolvePath("database.db");

... which I believe is the method that works across both ios and android (though android is all Im concerned with at the moment). thanks for your help - cant believe I missed that earlier. I'll blame lack of sleep.


Solution

  • Problem solved.... turns out i used different paths the database in the app... applicationDirectory in some places and applicationStorageDirectory in others.... so I changed all to:

    File.applicationStorageDirectory.resolvePath("database.db");
    

    ... which I believe is the method that works across both ios and android (though android is all Im concerned with at the moment). thanks for your help - cant believe I missed that earlier. I'll blame lack of sleep.