Home > Development > blogs
In the previous article, I examined the process for running a simple SELECT query on a pre-populated SQLite database in AIR. In today's example, I will actually execute a simple SELECT query and use the results to populate a data grid. I will also look at how to include a pre-populated database with an AIR application.
Retrieving Query Results
The query results can be retrieved from the instance of the SQLStatement class that was executed. They can be retrieved by calling the getResult of this instance. This will return an Array of results. The SQLEvent that is dispatched when the query is complete will contain a reference to the SQLStatement that fired it. You can get the results with this code:
var r:SQLResult = SQLStatement(event.target).getResult();
As you can see from the code, the value that is returned is of type SQLResult (link to documentation below). The data property of this class provides an Array of objects for your query results. This can be seen in the image below (which shows what the data property looks like inside of Flex Builder's variables view).
Including a Pre-Populated Database
If you need to include a database with your AIR application, the process is quite simple. You will need to follow these steps:
- Create your SQLite database with one of the tools mentioned in my first article in the series
- Place the file in your root source directory (the same directory as your application descriptor file).
- The file can now be referenced in the application directory (as shown earlier).
It would be a good idea to move the file to the application storage directory for each user (this directory is unique per user). To do this, you would simply need to check on launch to see if the file existed. If not, you could simply copy it over to the application storage directory. This is ideal especially if this data will be edited by the end user.
Sample Application
I have included a sample AIR application which includes a sample SQLite database of fake names and email addresses (generated by FakeNameGenerator.com). This table has 500 rows.
When the application launches, you will see a connect button enabled. When you click this button, it will connect to the database, and you can then click the query button. This will execute the sample query and populate the data grid below with the data from the query.
As always, View Source is enabled on this application (and you can also download the source below).
Application Source Code
Download (16.4 kb)
Reference
SQLResult [ ActionScript, JavaScript ]
- comments: 1
Comments
1 Comments
Leave a comment
Stay Connected
 InsideRIA Atom Feed
InsideRIA Development Atom Feed
InsideRIA Newsletter
↑ Put InsideRIA News on Your Site
Search InsideRIA
News & Events
Latest Features
Tag Cloud
- .net
- 3d
- actionscript
- adam flater
- adobe
- air
- air api
- air cookbook
- air resources
- air xml webkit
- ajax
- ajaxworld
- alertthingy
- amp
- analytics
- ant
- antipattern
- api
- appengine
- apple
- april fools day
- aptana
- architecture
- asp
- away3d
- aws
- bad usability calendar
- benchmarking
- berlin
- beta
- bitmaps
- blazeds
- blendmode
- book
- browserplus
- cairngorm
- camp
- career
- chart
- cloud
- code
- code generation
- coldfusion
- command design pattern
- communication
- community
- compiler
- component
- compression
- conference
- cs4
- curl
- customer
- cuzillion
- dare
- data
- datavisualization
- dbunit
- ddlutils
- debug
- decompiler
- deep zoom
- degrafa
- design
- design patterns
- desktop
- development
- diary
- dionalmaer
- drawing api
- dreamweaver
- drupal
- ejb 3.0
- elixir
- embedded jboss
- encryption
- europe
- event
- excerpt
- experience
- ext
- externalinterface
- eyetracking
- features
- filters
- fireworks
- fitc
- flash
- flash10
- flashforward
- flashplayer
- flex
- Flex
- flexbuilder
- flexunit
- form factor
- framework
- friendfeed
- gadget
- gears
- gesture
- googledocs
- googlegears
- graphics
- graphics mask
- guimark
- hosting
- how-to
- html
- ia
- ie
- ie8
- igoogle
- interaction
- interface
- interview
- iphone
- iphonedevcamp
- j2ee
- jakob
- java
- javafx
- javaone
- javascript
- javase
- javase6
- jaxer
- jms
- job
- joyent
- keynote
- languages
- lcds
- learning
- lffs
- library
- licensing
- linux
- listen
- livecycle data services
- madrid
- map
- marketing
- math
- maturity
- maven
- memory
- merapi
- mesh
- metrics
- microsoft
- mikepotter
- mix08
- mobile
- model locator design pattern
- mono
- mozilla
- mvc
- mxmlc
- neilson
- nio
- nitro
- nitrolm
- offline
- onairbustour
- onairtour
- onairtoureurope
- ontologies
- oop
- open source
- OpenFlux
- openscreen
- opensource
- orm
- papervision3d
- paris
- pattern
- pattern mining
- performance
- php
- podcast
- portable
- preload
- pricing
- prism
- Processing
- profiler
- protagonize
- push
- rails
- release
- research
- resources
- ria
- ria community
- rich
- ruby
- sanctuary
- scheduling
- scott sheridan
- search
- security
- seo
- server
- service oriented architecture
- services
- session bean
- silverlight
- singularity
- social
- source
- spain
- spry
- sqlite
- static code
- steveounders
- stockholm
- streaming
- survey
- swc
- swf
- switchboard
- syscon
- test driven development
- testing
- testng
- thermo
- tip
- tools
- trends
- tufte
- tutorial
- ui
- ui pattern library design
- uirc
- unconference
- unit testing
- usability
- user experience
- ux
- vector images
- view source
- vision
- warsaw
- wdn08
- web
- web 2.0
- web 2.0 expo
- whenisgood
- why
- widgets
- workshop
- wwdc
- xulrunner
- yahoo
- yui
Related Books
Development Series
Get an overview of the tools and technologies that work together to allow developers to build Rich Internet Applications (RIAs) quickly and easily.
Recent Comments
Archives
About This Site
Welcome to the premiere community site for all things RIA sponsored by O'Reilly Media and Adobe Systems Incorporated.
About Us
Meet the Experts
Meet Our Contributors
Send Us Feedback



Read your article,better than read a lot of books