0 Replies Latest reply on Aug 10, 2010 9:30 AM by guyoha

    when creating new table in sqllite db via Flex it become encoded as "utf-16le"

    guyoha

      Hi Guys

      I have some annoying problem with my AIR application

      The application is communicating with a local DB (sqllite).

      as part of initial installation I'm checking if the db exist.

      in case not then:

      1. I create one (file)
      2. create the relevent tables inside
      3. and populate them.

      For some reason, on the tables creation step the sqllite db become encoded as UTF-16le instead of UTF-8.

      The question is how can I make the tables creation step to leave the db as UTF-8

       

      thanks in advance for your help.

       

      This is my creation code

       

      1. the "connection" is from flash.data.SQLConnection type
      2. The "file" contain the following information

         

        <sql>
        <statement>
        CREATE TABLE IF NOT EXISTS MYTABLE
        (
              MYTABLE_VERSION                NUMBER NOT NULL,
               MYTA|BLE_INSERT_DATE                 DATE NOT NULL
        )
        </statement>

        </sql>
      3. The below is the relevent code:

       

      var stream:FileStream = new FileStream();
                 
                  stream.open(file, FileMode.READ);
                  var xml:XML = XML(stream.readUTFBytes(stream.bytesAvailable));
                  stream.close();
                  var statement:XML = null;
                 
                  try
                  {
                      connection.begin(lockType);
                     
                      for each (statement in xml.statement)
                      {
                         
                          var stmt:SQLStatement = new SQLStatement();
                          stmt.sqlConnection = connection;
                          stmt.text = statement;
                          stmt.execute();           
                      }
                  } catch(err:Error)
                  {
                      connection.rollback();
                      throw err;
                  }
                  connection.commit();