Skip to main content
Paly_Palovie
Participant
June 3, 2013
Question

SQLite save data to BLOB problem

  • June 3, 2013
  • 0 replies
  • 425 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.