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); };
Your Answer
Think you can help? Login to answer this question!