Skip to main content
Paly_Palovie
Participant
May 22, 2013
Question

SQLite save to BLOB problem

  • May 22, 2013
  • 1 reply
  • 642 views

Hi,

I have problem with BLOB in SQLite using Adobe Flash Builder 4.6

I am able to read BLOB data using cast to ByteArray:

protected function getBlob_clickHandler(event:MouseEvent):void

{

          var file:File = File.documentsDirectory.resolvePath(myPath);

          var sqlConnection:SQLConnection = new SQLConnection();

          try

          {

                    sqlConnection.open(file);

                    var stt:SQLStatement = new SQLStatement();

                    stt.sqlConnection = sqlConnection;

                    stt.text = "select SpeciesNo, CAST(Image as ByteArray) as ImageData from biolife where SpeciesNo=90310";

                    stt.execute();

                    var result:SQLResult = stt.getResult();

                    if ((result.data != null) && (result.data[0].ImageData != null))

                    {

                              myByteArray = result.data[0].ImageData;

                              //Show in image

                              MyImage.source = myByteArray;

                    }

          }

          catch(e:SQLError)

          {

                    trace("Error : " + e.details);

          }

}

Problem is in case of save BLOB to SQLite's db:

protected function setBlob_clickHandler(event:MouseEvent):void

{

          if (myByteArray == null) return;

          var file:File = File.documentsDirectory.resolvePath(myPath);

          var sqlConnection:SQLConnection = new SQLConnection();

          try

          {

                    sqlConnection.open(file);

                    var stt:SQLStatement = new SQLStatement();

                    stt.sqlConnection = sqlConnection;

                    stt.text = "update biolife set Image=:p1 where SpeciesNo=90310";

                    stt.parameters[":p1"] = myByteArray;

                    stt.execute();

          }

          catch(e:SQLError)

          {

                    trace("Error : " + e.details);

          }

}

I think problem is in AMF. Flash everytime put AMF to BLOB and I dont need it.

My goal is to edit DB which is using by original software.

When I change BLOB  then original software is not able to work with that BLOB.

So question is :

How to store BLOB without AMF ( I hope its AMF)?

Thank you.

This topic has been closed for replies.

1 reply

chris.campbell
Legend
May 23, 2013

You might have better luck with this over in the Development forum as I don't have much experience using SQL in AIR.  I've seen documentation for reading without AMF data present (as you are doing), but I suspect writing is not supported.

Paly_Palovie
Participant
May 24, 2013

Thanks for information. I supposed that kind of answer. I spend a lot of hours to solve this problem and all my experiments was unlucky. In case you are right  and Adobe does not support storing data to BLOB (without AMF), its big problem. I am coding soft. about 20 years and never meet situation : " this is not possible ". I hope I will found some solution.

I will try to to post in forum you wrote. Thank you again.