0 Replies Latest reply on Oct 28, 2009 6:36 AM by garindeathray

    Flex / Air sqlite async issue

    garindeathray

      Hi,  I am writing an app that parses a csv file to an array and then insert the array into a sqlite database. I am having issues with Async connection to the sqlite database, I get a 3106 error...... I think the problem is that it executes the next statement before the previous is finished but I can't find a way to deal with this. Any help would be greatly appreciated.

       

      public function addData(categories:Array):void{ 
      status = "Adding data to table"; 
      var insrtStmt:SQLStatement = new SQLStatement(); 
      insrtStmt.sqlConnection = conn; 
      for(var i:int=categories.length-1; i>=0; i--){ 
      insrtStmt.text = ""; 
      insrtStmt.text += "INSERT INTO masterlist "; 
      insrtStmt.text += "(mainid, transactionDate, tradeId, ccyPair, account, buySell, customer, date,"; 
      insrtStmt.text += " additionalid, dealType, traderName, genericType, owner) "; 
      insrtStmt.text += "VALUES(@mainid, @transactionDate, @tradeId, @ccyPair, @account, @buySell, @customer, @date,"; 
      insrtStmt.text += " @additionalid, @dealType, @traderName, @genericType, @owner);"; 
      insrtStmt.parameters["@mainid"] = categories[i].mainid; 
      insrtStmt.parameters["@transactionDate"] = categories[i].transactionDate; 
      insrtStmt.parameters["@tradeId"] = categories[i].tradeId; 
      insrtStmt.parameters["@ccyPair"] = categories[i].ccyPair; 
      insrtStmt.parameters["@account"] = categories[i].account; 
      insrtStmt.parameters["@buySell"] = categories[i].buySell; 
      insrtStmt.parameters["@customer"] = categories[i].customer; 
      insrtStmt.parameters["@date"] = categories[i].date; 
      insrtStmt.parameters["@additionalid"] = categories[i].additionalid; 
      insrtStmt.parameters["@dealType"] = categories[i].dealType; 
      insrtStmt.parameters["@traderName"] = categories[i].traderName; 
      insrtStmt.parameters["@genericType"] = categories[i].genericType; 
      insrtStmt.parameters["@owner"] = categories[i].owner; 
      insrtStmt.execute(); 
      } 
      }