Note that there are some explanatory texts on larger screens.

plurals
  1. POsqlite prepare statement error - no such table
    text
    copied!<p>I'm having some difficulty with my sqlite prepare statement. I get an error saying my table does not exist, although I've checked in multiple places for it, and it does exist, so I'm confuzzled. </p> <ul> <li>The file is in the correct iPhone Simulator Application folder </li> <li>The file is added to my project and viewable in the project navigator</li> <li>It is also in my build phases- Copy Bundle Resources area. </li> <li>I've cleaned and started running again.</li> <li><p>The database exists and running my sql statement gets me just the results I expected.</p> <pre><code>- (NSMutableArray *) getMyWorkout{ NSMutableArray *workoutArray = [[NSMutableArray alloc] init]; @try { NSFileManager *fileMgr = [NSFileManager defaultManager]; NSString *dbPath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"IOSDB.sqlite"]; NSLog(@"Db path is %@",dbPath); BOOL success = [fileMgr fileExistsAtPath:dbPath]; if(!success) { NSLog(@"Cannot locate database file '%@'.", dbPath); } if(!(sqlite3_open([dbPath UTF8String], &amp;db) == SQLITE_OK)){ sqlite3_close(db); NSLog(@"Failed to open database with message '%s'.", sqlite3_errmsg(db)); } const char *sql = "SELECT Id, type, difficulty, duration, description FROM workoutTbl"; sqlite3_stmt *sqlStatement; if(sqlite3_prepare(db, sql, -1, &amp;sqlStatement, NULL) != SQLITE_OK){ NSLog(@"%s Prepare failure '%s' (%1d)", __FUNCTION__, sqlite3_errmsg(db), sqlite3_errcode(db)); } //... </code></pre></li> </ul> <p>When I run it, I get the file path and the following error</p> <pre><code> 2013-02-01 18:07:08.060 TriShake[9251:c07] -[MyWorkoutList getMyWorkout] Prepare failure 'no such table: workoutTbl' (1) </code></pre> <p>I've checked out these other questions, but have been unable to find a solution</p> <ul> <li><a href="https://stackoverflow.com/questions/12746484/sqlite-prepare-failed-no-such-tabletablename">Sqlite Prepare Failed: no such table&lt;tablename&gt;</a></li> <li><a href="https://stackoverflow.com/questions/672829/sqlite3-gives-no-such-table-error-on-iphone">Sqlite3 gives &quot;no such table&quot; error on iPhone</a></li> </ul> <p>I understand sqlite3_open() creates an empty database for you if the database path does not exist, but i know it exists, so frustration ensues. Any help or guidance you could give me would be much appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload