Skip navigation
tedalde2
Currently Being Moderated

SQLError #3125

Feb 17, 2010 1:54 PM

Is this a bug or a feature? I can create a db directly inside ApplicationStorage, but not inside a (non-existent) folder in Application Storage. I get the error: SQLError: 'Error #3125: Unable to open the database file.', details:'Connection closed.', operation:'open', detailID:'1001'

 

As an example, open an AIR FLA and simply test these paths to the db file:

 

var dbpath:String = File.applicationStorageDirectory.url + "db/mydb"; // fails unless db is there already

var dbpath:String = File.applicationStorageDirectory.url + "mydb"; // works regardless, even if the local storage folder does not exist yet

 

var f:File = new File(dbpath);

var sql:SQLConnection = new SQLConnection();

sql.open(f, SQLMode.CREATE, false, 1024, null); // runtime error if path 1 is used.

 

(in flash CS4)

 

As a workaround I suppose I could, before creating the db, write a temp file to the path where the db should reside. That way, the path would exist. Is that the only way or am I missing something?

 

Thanks

 
Replies
  • Currently Being Moderated
    Feb 24, 2010 9:02 PM   in reply to tedalde2

    This is expected behavior.  The database will not create folders on your behalf.  To fix this you just need to add some code to ensure that the directory is already present.  For example:

     

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

    Hope that helps.
    jw

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points