title: SQLite iPhone SQL Select crashes application
body: <p>For some reason, my application fails at "NSAssert1(0, @"Error while looping search view. '%s'", sqlite3_errmsg(database));"
  The SQL Statement is OK, because I used the same statement, when I open the database.
  I don't get any useful errors :-(</p>
  
  <p>I'm quite new to this, but not a total stranger
  What am I doing wrong ?</p>
  
  <p>Please note I have taken out the "strSearch" to be sure this is not the error.</p>
  
  <pre><code>- (void)searchComponents:(NSString *)strSearch {
  
      NSString *qry;
  
      qry = [NSString stringWithFormat:@"SELECT ID, ON_SAP, SAP_PART, SAP_DESC, MOQ FROM HONEYWELL WHERE SAP_PART LIKE '%ZX%' ORDER BY SAP_PART", strSearch];
      NSLog(@"query : %@", qry);
  
      if(searchStmt == nil) {
          if(sqlite3_prepare_v2(database, [qry UTF8String] , -1, &amp;searchStmt, NULL) != SQLITE_OK)
              NSAssert1(0, @"Error while creating search view statement. '%s'", sqlite3_errmsg(database));
      }
  
      // Loop through the results
  
      if(sqlite3_step(searchStmt) == SQLITE_ROW) {
          // Read the data from the result row
          NSLog(@"New row selected");
      }
      else {
          NSAssert1(0, @"Error while looping search view. '%s'", sqlite3_errmsg(database));
      }
  
      // Release the compiled statement from memory
      sqlite3_finalize(searchStmt);
  
      // Set isDetailViewHydrated as YES, so we do not get it again from the database.
      isDetailViewHydrated = YES;
  }
  </code></pre>
  
  <p>The method is in it's own class (named Coffee) called from MasterViewController</p>
  
  <pre><code>- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
      NSLog(@"Text changed %@",searchText); 
      Coffee *coffeObj = [[Coffee alloc] init];
      [coffeObj searchComponents:@"%ZX%"];
  }
  </code></pre>
  
  <p>The idea is to change the select statement when searching from a search field..
  Does anybody know of a good example doing this ?</p>