"Uncaught Error: no such table"

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

Hi, Need help, every time when i tried to install the database on my application below mention error is shown.. Thanks in advance..

This is my code for database.. " var db=Ti.Database.install('/model/details.sqlite','done'); db=Titanium.Database.open('done');
var rows=db.execute('SELECT * FROM kisan'); db.close(); "

Message: Uncaught Error: no such table: kisan: , while compiling: SELECT * FROM kisan [ERROR][TiJSError( 341)] (main) [1,2410] - Source: var rows=db.execute('SELECT * FROM kisan'); [ERROR][V8Exception( 341)] Exception occurred at database/database.js:7: Uncaught Error: no such table: kisan: , while compiling: SELECT * FROM kisan

2 Answers

The error is pretty clear... the table kisan doesn't exist in your database.

Keep in mind that install() will only copy the database over if it wasn't already previously installed. My guess, you previously installed it, made changes, and didn't un-install your app from your simulator/device before trying again.

Hello Pratik, I suppose you are very sure that your database is at /model/details/details.sqlite, as we discussed earlier (don't you sleep?, ne.. me neither)...

when you "fails" to create the database, you create an EMPTY database, that is why you don't have any tables. Go to the settings->app->you app->clear data (here you are clearing the data, the bad one or the good one)

Re run your application and you should re install your database.

If you are unsure you could:

var hasDB=TI.database.open('done'); //will open the current database, if not exists, will create an empty one
hasDB.remove();//REMOVE the database
hasDB.close();//close de object 
hasDB=null;//let the garbage collector pick up this
var db=Ti.Database.install('/model/details.sqlite','done');
You don't have to OPEN the database again, the installation return a db object already opened.

What I'm dong is "fixing things using brute force". Open the database. DELETE de database Re-install the database :)

Your Answer

Think you can help? Login to answer this question!