I have a mobile app with a SQLite database to store details on the handset, I want to sync the contents of this table via PHP to a remote mySQL server.
I use the following to write the rows to the remote server.
protected function button_clickHandler(event:MouseEvent):void
{
var result:SQLResult;
var numRows:int ;
conn = new SQLConnection();
conn.open(file, SQLMode.CREATE);
selectStmt.sqlConnection = conn;
var sql:String = "SELECT * FROM surveyResponseHeader";
selectStmt.text = sql;
selectStmt.execute();
result = selectStmt.getResult();
numRows = result.data.length;
trace (result.data.length);
trace (numRows);
for (var i:int = 0; i< numRows; i++){
surveyresponse.surveyID = parseInt(result.data[i]["surveyID"]);
surveyresponse.surveySite =result.data[i]["surveySite"];
surveyresponse.surveyReference = result.data[i]["surveyReference"];
surveyresponse.siteManager =result.data[i]["siteManager"];
surveyresponse.surveyDate = result.data[i]["surveyDate"];
surveyresponse.surveyNextVisit = result.data[i]["surveyNextVisit"];
surveyresponse.surveySignature = result.data[i]["surveySignature"];
surveyresponse.surveyImage =result.data[i]["surveyImage"];
surveyresponseheaderService.createSurveyresponseheader(surveyresponse);
}
}
My question:
On the first run only the last row is posted and it is posted multiple times depending on the number of rows returned by the SQLLite query, on the second run it posts properly, why is this?
I have stared at this now for hours and cannot see where I am going wrong.
Any suggestions appreciated.
I suggest you to add events listeners:
then in handler check results:
as described in help for execute() method