App keeps crashing when executing a database command

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

Howdy,

My app keeps crashing every time I try to execute a SQL query. Below is a snippet of code that should install a preexisting database called products.sqlite, open the database, then drop a table called products if it exists.

Ti.Database.install('products.sqlite', 'productDB');
var db = Ti.Database.open('productDB');
 
db.execute('DROP TABLE IF EXISTS products');    // Remove the products table
Am I installing or opening the database incorrectly? This is an iPad app on iOS 4.2.

2 Answers

Accepted Answer

Indeed, install does install and open the database. However, the apidocs explain that the arguments of Ti.Database.install are actually path and name.

This is explained in more detail in the SQLite Databases guide.

— answered 2 years ago by Paul Dowsett
answer permalink
6 Comments
  • Scott, were you able to solve this? If so, would you mind posting the steps you took next to the answer that helped you most, and then close the post so that others may find it easily in future? This is explained in the Participating in the Q&A guide. Thanks a lot :)

    — commented 2 years ago by Paul Dowsett

  • This is a project for work and I had to take a break to focus on other tasks. I'll try your suggestion out soon and let you know how it worked out if me. If it proves successful, I'll be sure to mark your answer and close the case. Thanks for the help!

    — commented 2 years ago by Scott Heath

  • You are welcome, Scott. Of course, if you still need help with this, just update the thread and I will try again. :)

    Good luck!

    — commented 2 years ago by Paul Dowsett

  • Show 3 more comments

What if you combine the first two lines into:

var db = Ti.Database.install('products.sqlite', 'productDB');
The install will do an install and/or open, so calling the open again might be the problem.

Your Answer

Think you can help? Login to answer this question!