Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol ( or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
The most up-to-date version of this article is on my Blog
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…

715 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