Improve company productivity with a Business Account.Sign Up


Whats the problem with this connection from Javasript to SQLITE on Adobe Air?

Posted on 2009-05-20
Medium Priority
Last Modified: 2012-08-13
The code from the SQLite connection and the select i taked from the Adobe Air HTML/Javascript manual, but im pretty confused.

The connection to the DB works, but when i execute the datosBD() function for the select statement from the Adobe Air Introspector, well that doesnt work.

And in the debug window it tells me the next:
"Error message: Error #3115: SQL Error.
Details: no such table: 'prueba'.

I know the connection its open, and i know my db works, because i opened it with sqliteadmin, sqlite Maestro, and SQLite Professional and i executed some SELECT querys like this.

SELECT * FROM prueba
SELECT Nombre, Paterno FROM prueba.

I just dont know why from the Adobe Air it keeps telling me theres an error.

Thanks in advance, and sorry for my bad english as im from Mexico.

var conn = new air.SQLConnection(); 
conn.addEventListener(air.SQLEvent.OPEN, openHandler); 
conn.addEventListener(air.SQLErrorEvent.ERROR, errorHandler); 
var dbFile = air.File.applicationStorageDirectory.resolvePath("sist.db"); 
conn.openAsync(dbFile, air.SQLMode.READ); 
function openHandler(event) 
    air.trace("the database opened successfully"); 
function errorHandler(event) 
    air.trace("Error message:", event.error.message); 
    air.trace("Details:", event.error.details); 
alert('No conectado');
function datosBD(){
// ... create and open the SQLConnection instance named conn ... 
// create the SQL statement 
var selectStmt = new air.SQLStatement(); 
selectStmt.sqlConnection = conn; 
// define the SQL text 
var sql =  
    "SELECT Nombre, Paterno " +  
    "FROM prueba"; 
selectStmt.text = sql; 
// register listeners for the result and error events 
selectStmt.addEventListener(air.SQLEvent.RESULT, selectResult); 
selectStmt.addEventListener(air.SQLErrorEvent.ERROR, selectError); 
// execute the statement 
function selectResult(event) 
    // access the result data 
    var result = selectStmt.getResult(); 
    var numRows =; 
    for (i = 0; i < numRows; i++) 
        var output = ""; 
        for (columnName in[i]) 
            output += columnName + ": " +[i][columnName] + "; "; 
        air.trace("row[" + i.toString() + "]\t", output); 
function selectError(event) 
    air.trace("Error message:", event.error.message); 
    air.trace("Details:", event.error.details); 

Open in new window

Question by:DataGranger
LVL 20

Expert Comment

ID: 24432257
I think the message says all ... there is no such table. One thing you should check though, is if you eventually need to add a shema. In MySQL for example, if you don't logon to the db using a default shema, then you need to add it to the table name. So maybe your Statement should be :
"SELECT Nombre, Paterno  FROM schemaname.prueba"

Accepted Solution

DataGranger earned 0 total points
ID: 24436247
Well i just found the answer, when you are working with sqlite on Adobe air,  and the Database its local and its prepopulated on the folder of your files. You have to copy the database to another file, because its read only.

As the manual says:

"Like all files that are included in an AIR package, a bundled database file is installed in the application directory (the directory represented by the File.applicationDirectory property). However, files in that directory are read only. Use the file from the AIR package as a template database. The first time a user runs the application, copy the original database file into the users application storage directory (or another location), and use that database within the application."

So once again, I read all the manual(RTFM),  and find my answer.

I attach the code that i used to copy the database prepopulated, im used sync DB.

Thanks in advance.

 var dbFile = air.File.applicationStorageDirectory.resolvePath("notes.db");
 //In production, uncomment the if block to maintain the database.
 if (!dbFile.exists) {
   var dbTemplate = air.File.applicationDirectory.resolvePath("sist.db");
   dbTemplate.copyTo(dbFile, true);  

Open in new window


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question