title: How to bind text value to sqlite3 database in iphone
body: <p>I am developing a app for a movie in which I need to fetch data from the database considering some constraints. It works perfectly on the first occasion, but when I try to fetch data 2nd time it throws a runtime exception( the app crashes).I have to bind 3 placeholders. 2 are text and 1 is integer type. Here's the code which I am using to fetch data from the database.</p>
  
  <pre><code>-(void) Data2
  {
   databaseName = @"Cinema1.sqlite";
  
   NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
   NSString *documentsDir = [documentPaths objectAtIndex:0];
   databasePath =[documentsDir stringByAppendingPathComponent:databaseName];
  
   [self checkAndCreateDatabase];
  
  
   sqlite3 *database;
   if (sqlite3_open([databasePath UTF8String], &amp;database) == SQLITE_OK)
   {
    if(detailStmt == nil)
    {
     const char *sql = "Select PVR,Fame,Cinemax,Big from listing where UPPER(State) = UPPER(?) and UPPER(City) = UPPER(?) and ZIP = ?";   
     if(sqlite3_prepare_v2(database, sql, -1, &amp;detailStmt, NULL) == SQLITE_OK) 
     {  
      NSLog(@"Hiiiiiii");
      sqlite3_bind_text(detailStmt, 1, [t1 UTF8String], -1, SQLITE_TRANSIENT);
      sqlite3_bind_text(detailStmt, 2, [t2 UTF8String], -2, SQLITE_TRANSIENT);
      sqlite3_bind_int(detailStmt, 3, t3);
      if(SQLITE_DONE != sqlite3_step(detailStmt))
      {
       NSLog(@"Helllloooooo");
       NSString *pvr= [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 0)];
       NSString *fame= [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 1)];;
       NSString *cinemax = [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 2)];
       NSString *big= [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 3)];
       pvr1 = pvr;
       fame1 = fame;
       cinemax1 = cinemax;
       big1 = big;
       NSLog(@"PVR %@ Fame %@ Cinemax %@ Big %@",pvr1,fame1,cinemax1,big1);
      }
     }
     sqlite3_finalize(detailStmt);
    }
   }
   sqlite3_close(database);}
  </code></pre>
  
  <p>Can anyone help me with this.</p>