Simon Slavin-3 wrote:
> 
> 
> On 15 Nov 2011, at 11:09pm, BertD wrote:
> 
>> When i'm working with the db in Flex, i'm able to Query the db I want,
>> but
>> am unable to "UPDATE" nor "INSERT" ?
> 
> My guess is that you're opening a database file with the same name, but in
> a different directory.  Or that you do have the database file protected by
> some part of your file system and it's opening as read-only.
> 
> When you do queries, are you actually reading out records in that
> database, or does it always return no rows ?
> 
>> Is there any off-the-bat reason why
>> this would be (like read-only setting i cannot find) 
> 
> well, there's one in the open() call.  Did you find that ?
> 
> Simon.
> 
> 

At the moment this is how i'm working this :
// first we need to set the file class for our database (ICM.db). 
    var db:File = new File ("C:/ICM.db");
// after we set the database file we need to open it with our SQLConnection. 
    SQLc.openAsync(db); <-- using openAsync()
// EventListener on open
    SQLc.addEventListener(SQLEvent.OPEN, db_opened);
// EventListener on result
    SQLCust.addEventListener(SQLEvent.RESULT, custResult);
//does the following
private function db_opened(e:SQLEvent):void
{
        // when the database is opened we need to link the SQLStatement(s) to 
our
SQLConnection, so that the SQL-statement(s) target the right database.
        // if we don't set this connection we'll get an error when we execute 
SQL
statement.
        SQLCust.sqlConnection = SQLc;
       //would it be 'bad' if i had a second SQLStatement from the same
connection here ? 
       SQLVend.sqlConnection = SQLc;
        refreshSQLCust();
}
// function to call when we want to refresh the data in datagrid
private function refreshSQLCust(e:TimerEvent = null):void
{
        // timer object which we need if SQL-statement is still executing so 
that
we can try again after 10 milliseconds.
        var timer:Timer = new Timer(10,1);
        timer.addEventListener(TimerEvent.TIMER, refreshSQLCust);
        
        if ( !SQLCust.executing )// we need to check if our SQL-statement is 
still
executing our last SQL-command. If so we use Timer to try again in 10
milliseconds. If we wouldn't check we could get an error because the
SQL-statement can't execute two statements at the same time.
        {
                // SQL-statement which returns all the data from our CustTable.
                SQLCust.text = "SELECT * FROM CustComTable"
                SQLCust.execute();
        }
        else
        {
                timer.start();
        }
}
private function custResult(e:SQLEvent):void
{
        // with SQLs.getResult().data we get the array of objects for each row 
out
of our database
        var data:Array = SQLCust.getResult().data;
        // we pass the array of objects to our data provider to fill the 
datagrid
        CustDp = new ArrayCollection(data);
}

-- 
View this message in context: 
http://old.nabble.com/Adobe-Air---Using-SQLite-db%2C-cannot-%22UPDATE%22-nor-%22INSERT%22-tp32851221p32852846.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to