Greetings,

I am trying to write a ViewStack with various radio buttons to a local database 
and then retrieve it in its saved (persisted) state but I am not having any 
success. Is it even possible to write/read a ViewStack to a database? I can 
write and retrieve strings, numbers, dates, and arrays, but not the ViewStack 
(nor a Dictionary).

private function writeToDatabase():void{
        // Type to itemClass
        item.status = 1;
        item.date = new Date();
        item.name = "test quote";
        item.cartDP = cartDP;
        item.productData = productVS;
        
        var params:Array = [ item.status, item.date, item.name, item.cartDP, 
item.productData ]
        var stmt:String =       "INSERT INTO Quote (status, date, name, cartDP, 
productData)";
        trace (stmt);
        sqlConnection.insert( stmt, params );
}

public function insert( sqlStmt:String, params:Array = null ):void{
        var sqlInsert:SQLStatement = new SQLStatement();
        sqlInsert.sqlConnection = sqlConnection;
        
        //  ADD EVENT LISTENERS
        sqlInsert.addEventListener(SQLEvent.RESULT, onInsertSuccess);
        sqlInsert.addEventListener(SQLErrorEvent.ERROR, errorHandler);
        
        // ASSIGN PARAMETERS
        if( params ) {
                for( var i:int = 0; i < params.length; i++ ) {
                        sqlInsert.parameters[i] = params[i];
                }
        }
        sqlInsert.itemClass = ItemTO;

        // EXECUTE SQL ACTION
        sqlInsert.execute();
} // END insert()

And this is all written to my local database, but when I read this back in I 
get Error #1009: Cannot access a property or method of a null object reference 
for the ViewStack even though there is data being returned from the query. I've 
even tried turning it into a byteArray: 

        var bytes:ByteArray = new ByteArray();
        bytes.position = 0;
        bytes.writeObject(productVS);

But when I read it back, even though the ByteArray has data, I can't get it 
back into a ViewStack
        var bytes:ByteArray = new ByteArray();
        bytes = event.results[0]["productData"];
        bytes.position = 0;
        var newVS:Dictionary = bytes.readObject() as ViewStack;

I am really spinning my wheels on this one and could really use some 
ideas/comments on what I am doing wrong or if this is even possible.

Thanks,
Mike




-------------------------------------------------------------

To unsubscribe from this list, simply email the list with unsubscribe in the 
subject line



For more info, see http://www.affug.com

Archive @ http://www.mail-archive.com/discussion%40affug.com/

List hosted by http://www.fusionlink.com

-------------------------------------------------------------

Reply via email to