0 Replies Latest reply on Jan 28, 2009 9:58 PM by monkeynote

    Multiple Insert Problem in Adobe AIR

    monkeynote Level 1
      hello guys!

      im new to adobe air and i just want to say that AIR is Awesome! :)

      i would like to ask guys if you encounter this problem about multiple query in adobe air. i am using asynchronous access to sqllite database. i have a text to parse ("%%EmployeeName1$$Address1$$ContactNo1%%EmployeeName2$$Address2$$ContactNo2%%EmployeeNam e3$$Address3$$ContactNo3;")
      about 230 records and i would like to dump this text into sqllite database but, i encountered this problem that halts me with populating Employees table.

      quote:


      Error: Error #3106: Property cannot be changed while SQLStatement.executing is true.
      at Error$/throwError()
      at flash.data::SQLStatement/set text()



      here is my code
      quote:


      private function ParseString():void
      {
      var EmployeeNo:String = "%%EmployeeName1$$Address1$$ContactNo1%%EmployeeName2$$Address2$$ContactNo2%%EmployeeName 3$$Address3$$ContactNo3;
      var arr1:Array = EmployeeNo.split("%%");
      var sql:String;
      var SeQueLStatement:SQLStatement = new SQLStatement();
      SeQueLStatement.sqlConnection = conn;
      sql = "INSERT INTO Employees (EmpName, Address, Telephone) VALUES (:EmpName, :Address, :Telephone)";
      for each (var Employee:String in arr1){
      var arr2:Array = Employee.split("$$");
      SeQueLStatement.parameters[":EmpName"] = arr2[0];
      SeQueLStatement.parameters[":Address"] = arr2[1];
      SeQueLStatement.parameters[":Telephone"] = arr2[2];
      SeQueLStatement.text = sql;
      // Pass SQL Statement with Parameters
      addData(SeQueLStatement);
      }
      // Retrieve Append Records
      getData();
      }
      private function addData(sqlState:SQLStatement):void
      {
      // "Adding data to table";
      sqlState.addEventListener(SQLEvent.RESULT, insertResult);
      sqlState.addEventListener(SQLErrorEvent.ERROR, insertError);

      sqlState.execute();
      }

      private function insertResult(event:SQLEvent):void
      {
      var stmt:SQLStatement = event.target as SQLStatement;
      stmt.removeEventListener(SQLEvent.RESULT, insertResult);
      stmt.removeEventListener(SQLErrorEvent.ERROR, insertError);
      }

      private function insertError(event:SQLErrorEvent):void
      {
      insertStmt.removeEventListener(SQLEvent.RESULT, insertResult);
      insertStmt.removeEventListener(SQLErrorEvent.ERROR, insertError);

      trace("INSERT error:", event.error);
      trace("event.error.message:", event.error.message);
      trace("event.error.details:", event.error.details);
      }



      what is wrong with my code? does adobe air supports multiple instances? what is the workaround to populate sqllite database?

      thanks for reading my post guys! i hope that you can help me with my problem :(