App crashes after inserting a record

You must Login before you can answer or comment on any questions.

Mobile application Titanium build: 2.1.2.201208301612 Platform iOS device: iPad

Good afternoon,

I am building a CRM application. In this app contacts are related to companies. When I'm inserting a contactperson the app crashes in the simulator when the tableviewRow needs to be drawn.

Any thoughts on this problem?


addConButton.addEventListener('click', function(e) {

if(firstNameInsert.value == "" || lastNameInsert.value == "" || relationInsert.value == ""){

    Titanium.API.info("Vul minimaal de naam in van de relatie");

}

else{

    function insertInternal(){

    var db = Titanium.Database.open("database");

db.execute('INSERT INTO contacts(last_name, first_name, phone1, email1, funct) VALUES (?,?,?,?,?)', lastNameInsert.value, firstNameInsert.value, phoneInsert.value, emailInsert.value, functInsert.value);

    db.close();
    return true;

}

});


Thanks in advance.

1 Answer

Do you have any constraint in your table definition that would prevent the record from being inserted (like a null value in one of the fields) ? you should try to catch the error as follows.

try{
    db.execute('INSERT INTO contacts(last_name, first_name, phone1, email1, funct) VALUES (?,?,?,?,?)', 
    lastNameInsert.value, firstNameInsert.value, phoneInsert.value, emailInsert.value, functInsert.value);
    } catch (e) {
        alert(e);
};

— answered 9 months ago by Sebastien Jacq
answer permalink
2 Comments
  • Thank you, Sebastian for your reply. I've already tried to catch the error. No error shows up but the crash remains.

    — commented 9 months ago by Peter Flink

  • what's the type of the fields you got defined in the database ?

    — commented 9 months ago by Sebastien Jacq

Your Answer

Think you can help? Login to answer this question!