Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning AIR: Building Applications for the Adobe Integrated Runtime ISBN: 978-0-470-22904-0
This is the forum to discuss the Wrox book Beginning AIR: Building Applications for the Adobe Integrated Runtime by Rich Tretola; ISBN: 9780470229040
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning AIR: Building Applications for the Adobe Integrated Runtime ISBN: 978-0-470-22904-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 15th, 2009, 05:54 PM
Registered User
 
Join Date: Nov 2007
Location: ta, -, Israel.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Air and sqlite problem

Hi,

I have minimized the code from chapter 11 and modified to my need. Mainly, to open and run a query.

The code is:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
width="700" height="400">
<mx:Script>
<![CDATA[
import mx.core.Application;
]]>
</mx:Script>
<mx:Script>
<![CDATA[

import flash.data.SQLResult;
import flash.data.SQLStatement;
import mx.controls.Alert;
import flash.filesystem.File;
import flash.data.SQLConnection;
import flash.events.SQLErrorEvent;
import flash.events.SQLEvent;

privatevar conn:SQLConnection;
privatevar createTableStatement:SQLStatement;
privatevar selectAllSQL:SQLStatement;

privatefunction openDatabase():void{
conn = new SQLConnection();
conn.addEventListener(SQLErrorEvent.ERROR, errorHandler);

var dbFile:File = File.applicationStorageDirectory.resolvePath("cri2.db3");
if(dbFile.exists) {
conn.addEventListener(SQLEvent.OPEN, openHandler);
} else {
conn.addEventListener(SQLEvent.OPEN, createHandler);
}
conn.open(dbFile);
}

privatefunction errorHandler(event:SQLErrorEvent):void {
var err:String = "Error id:" + event.error.errorID + "\nDetails:" +
event.error.message;
Alert.show(err,"Error");
}

privatefunction createHandler(event:SQLEvent):void {
Alert.show("The database was created successfully", "createHandler");
}

privatefunction openHandler(event:SQLEvent):void {
Alert.show("The database was opened successfully", "openHandler");
}

privatefunction selectAllUsers():void{
var sqlText:String = 'SELECT route FROM cdata';
selectAllSQL = new SQLStatement();
selectAllSQL.sqlConnection = conn;
selectAllSQL.addEventListener(SQLEvent.RESULT, selectAllUsersResult);
selectAllSQL.addEventListener(SQLErrorEvent.ERROR, errorHandler);
selectAllSQL.text = sqlText;
selectAllSQL.execute();
}
privatefunction selectAllUsersResult(event:SQLEvent):void{
var result:SQLResult = selectAllSQL.getResult();
grid.dataProvider = result.data;
}

]]>
</mx:Script>
<mx:Button label="Create or Open Database" click="openDatabase()"/>
<mx:Button click="selectAllUsers()" label="Select All Users"/>
<mx:DataGrid id="grid" width="320" height="100"/>
</mx:WindowedApplication>


Unfortuntly, it does not run and I get this error:

SQLError: 'Error #3115: SQL Error.', details:'no such table: 'cdata'', operation:'execute', detailID:'2013'
at flash.data::SQLStatement/internalExecute()
at flash.data::SQLStatement/execute()
at cri_ax/selectAllUsers()[C:\Users\asher\Documents\Flex Builder 3\cri_ax\src\cri_ax.mxml:58]
at cri_ax/___cri_ax_Button2_click()[C:\Users\asher\Documents\Flex Builder 3\cri_ax\src\cri_ax.mxml:68]

Can someone help me and explain me why it does not work? and how to fix it.

Thanks in advance.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adobe AIR: Create-Modify-Reuse (978-0-470-18207-9) jaswanttak BOOK: Adobe AIR: Create - Modify - Reuse ISBN: 978-0-470-18207-9 3 April 16th, 2009 11:48 AM



All times are GMT -4. The time now is 03:22 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.