title: sqlite3_prepare error #26
body: <p>I have following code (modified code from this <a href="http://klanguedoc.hubpages.com/hub/Tutorial-on-Creating-an-IOS-5-SQLite-Database-Application-IOS-5-SQLite" rel="nofollow">tutorial</a>):</p>
  
  <pre><code>    -(NSMutableArray *) getChampionDatabase
  {
      NSMutableArray *championsArray = [[NSMutableArray alloc] init];
  
      @try {
  
      NSFileManager *fileManager = [NSFileManager defaultManager];
      NSString *databasePath = [[NSBundle mainBundle]pathForResource: @"Champions Database" ofType:@"sqlite"];
      BOOL success = [fileManager fileExistsAtPath:databasePath];
  
      if (!success)
      {
          NSLog(@"cannot connect to Database! at filepath %@",databasePath);
      }
  
      if(sqlite3_open([databasePath UTF8String], &amp;database) == SQLITE_OK)
      {
      const char *sql = "SELECT CHAMPION_ID,CHAMPION_NAME,CHAMPION_IMG FROM CHAMPIONS";
      sqlite3_stmt *sqlStatement;
  
      if(sqlite3_prepare(database, sql, -1, &amp;sqlStatement, NULL) == SQLITE_OK)
      {
          while (sqlite3_step(sqlStatement)==SQLITE_ROW) {
              championList *ChampionList = [[championList alloc]init];
              ChampionList.championId = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,0)];
              ChampionList.championName = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,1)];
              ChampionList.championImage = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement, 2)];
              [championsArray addObject:ChampionList];
      }
      }
          else
          {
              NSLog(@"problem with database prepare");
          }
      }
          else
          {
              NSLog(@"problem with database openning");
          }
      }
  
  @catch (NSException *exception)
      {
      NSLog(@"An exception occured: %@", [exception reason]);
      }
  @finally
      {
      return championsArray;
      }
  }
  </code></pre>
  
  <p>After running this code i always have output : "problem with database prepare" </p>
  
  <p>Then i tried to check error number of sqlite3_prepare by following code:</p>
  
  <pre><code>int ret = sqlite3_prepare(database, sql, -1, &amp;sqlStatement, NULL);
              if (ret != SQLITE_OK) {
                  NSLog(@"Error calling sqlite3_prepare: %d", ret);
              }
  </code></pre>
  
  <p><strong>output</strong>: "Error calling sqlite3_prepare: 26"</p>
  
  <p><strong>error 26</strong> - /*File opened that is not a database file */</p>
  
  <hr>
  
  <p>File have sqlite 3 version</p>
  
  <p>how is this possible? file extension is .sqlite and i can modify it in sqlite manager </p>