"no such table: Games. Routine works on iPhone 5.1 simulator, but not on the iPhone device
<p>I have an issue with loading my view (see below for code).  Basically, I am retrieving data from a table and displaying it on the iPhone screen.  </p>

<p>The <em>iPhone 5.1 simulator</em> works, however, I get the message on device</p>

<blockquote>
  <p>"Problem with prepare statement:  no such table: Games" </p>
</blockquote>

<p>Can anyone give me a little direction? </p>

<p>Thanks in advance for your time and comments.</p>

<p>Here is the code:</p>

<pre><code>-(NSMutableArray *) gameList{
 thegames = [[NSMutableArray alloc] initWithCapacity:5];
 @try {

    NSDate* date = [NSDate date];
    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"MM/dd/yyyy"];
    [formatter setDateFormat:@"MMdd"];
    NSString* str1 = [formatter stringFromDate:date];
    [toDaysDate setText:str1];

    NSFileManager *fileMgr = [NSFileManager defaultManager];

        NSString *docsDir;
        NSArray *dirPaths;

       dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
       docsDir = [dirPaths objectAtIndex:0];

    NSString *dbPath = [[NSString alloc]initWithString: [docsDir stringByAppendingPathComponent:@"sportretortdatab2.sqlite"]];        

    BOOL success = [fileMgr fileExistsAtPath:dbPath];
    if(!success)
    {
        NSLog(@"Cannot locate database file '%@'.", dbPath);
    }
    if(!(sqlite3_open([dbPath UTF8String], &amp;db) == SQLITE_OK))
    {
        NSLog(@"An error has occured: %s", sqlite3_errmsg(db));
    }

    const char* GamesSQLString(NSString* str1);

    NSString* sql= [NSString stringWithFormat:@"SELECT * FROM Games WHERE SeqNo= \"5\" AND GameDate &lt; \"%@\"", str1];
    sqlite3_stmt *sqlStatement;

// THIS IS WERE I GET THE ERROR - THIS STATEMENT WORKS ON iPhone Simulator 5.1, NOT on iPhone device /////// 

if(sqlite3_prepare_v2(db, [sql cStringUsingEncoding:NSASCIIStringEncoding], -1, &amp;sqlStatement, NULL) != SQLITE_OK)

////////////////////////////////////////////////////////////////////////////////////////

    {

         NSLog(@"Problem with prepare statement:  %s", sqlite3_errmsg(db));
    }else{
        while (sqlite3_step(sqlStatement)==SQLITE_ROW) {
            Game * game = [[Game alloc] init];
            game.GameDate = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,1)];
            game.Completed = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,13)];
            if ([game.Completed isEqualToString:@"N"]) {
                NSString * strRR = [NSString stringWithFormat:@"%@%@", game.GameDate, @" - Open"];
                game.GameDate = strRR;}
            else {
                NSString * strRR = [NSString stringWithFormat:@"%@%@", game.GameDate, @" - Completed"];
                game.GameDate = strRR;}
            [thegames addObject:game ];
        }
    }
}
@catch (NSException *exception) {
    NSLog(@"Problem with prepare statement:  %s", sqlite3_errmsg(db));
}
@finally {
    sqlite3_close(db);
    return thegames;
}
}
</code></pre>
