This content has been marked as final. Show 7 replies
are you in flash or flex? I have been beatin myself up for a couple days just trying to get a simple db connection and return on the stage...here is where I am so far... I am getting a return via the trace and a TextArea on the stage.
var conn:SQLConnection = new SQLConnection();
var dbFile:File = File.applicationDirectory.resolvePath("Playbook.db");
var taFiles:TextArea = new TextArea();
trace("the database opened successfully");
trace("Error message:", error.message);
// create the SQL statement
var selectStmt:SQLStatement = new SQLStatement();
selectStmt.sqlConnection = conn;
// define the SQL text
var sql:String =
"SELECT ID, inst_title, inst_desc " +
selectStmt.text = sql;
var result = selectStmt.getResult();
var numResults = result.data.length;
for (var i = 0; i < numResults; i++)
var row = result.data ;
var output = "<p> ID: " + row.ID;
output += "; inst_title: " + row.inst_title;
output += "; inst_desc: " + row.inst_desc;
output += "; <br>";
taFiles.appendText(output + "\n");
// Information about the error is available in the
// error variable, which is an instance of
// the SQLError class.
When I was following the livedocs I ran into that off the bat... it was the
if you have not installed the app, it wont exist (cant find the db) I switched it to
and placed the db in the same dir as my file
Applications should never create or write to files in File.applicationDirectory. While it will work in some situations, won't work on all operating systems.
The File.applicationStorageDirectory location always exists, even for applications that are not installed.
If the database file your attempting to open might not exist, be sure to open it with SQLMode.CREATE. Opening with mode UPDATE will fail if the file isn't there. (See the API docs for details.)
In the original post, it appears that the SELECT is being run asynchronously but the results queried without waiting for the operation to complete. This would likely explain why the results are empty.
Oliver Goldman | Adobe AIR Engineering
ok I changed it to this:
the trace output says the SELECT statement succeeded but then it triggers an error:
Error message : Null value
anyone? I know this thing just came out but jeez
What did you use to create your database? I was running into that error when I thought my SQlite db was up to the correct version. I ended up getting a copy of SQLite 2008 Pro and it confirmed I had a null value in my main index. Once I straightened that out I got my trace to return.
Now if someone could bend light and show me what I can do with my data to actually get it on screen that would rock the house.