title: sqlite3_prepare_v2 () - no such table
body: <p>I open the database, but when i check if the statement is OK, i get the following error.  </p>
  
  <pre><code>Error no such table: Event
  </code></pre>
  
  <p>Here is part of the code:</p>
  
  <pre><code>    if (sqlite3_open(dbpath, &amp;database) == SQLITE_OK)
      {
          NSString *querySQL = @"SELECT nic,subject,location,participants,startDate,endDate FROM Event";
          const char *query_stmt = [querySQL UTF8String];
  
          if (sqlite3_prepare_v2(database,query_stmt, -1, &amp;statement, NULL) == SQLITE_OK)
  </code></pre>
  
  <p>If i don´t open the database i don´t get any error, but if i call the function again i get:</p>
  
  <pre><code>library routine called out of sequence
  </code></pre>
  
  <p>The code to create the database:</p>
  
  <pre><code>-(BOOL)createDB
  {
      // Get the documents directory
      NSString *docsDir;
      NSArray *dirPaths;
      dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      docsDir = dirPaths[0];
      // Build the path to the database file
      databasePath = [[NSString alloc] initWithString:[docsDir stringByAppendingPathComponent: @"reglis.db"]];
      BOOL isSuccess = YES;
      NSFileManager *filemgr = [NSFileManager defaultManager];
      if ([filemgr fileExistsAtPath: databasePath ] == NO)
      {
          const char *dbpath = [databasePath UTF8String];
          if (sqlite3_open(dbpath, &amp;database) == SQLITE_OK)
          {
              char *errMsg;
  
              const char *sql_stmt ="DROP TABLE IF EXISTS Client;CREATE TABLE Client (nic VARCHAR PRIMARY KEY  NOT NULL  UNIQUE , name VARCHAR, location VARCHAR, postalCode VARCHAR);DROP TABLE IF EXISTS Meio;CREATE TABLE Meio (id_meio VARCHAR PRIMARY KEY  NOT NULL , nic VARCHAR, email VARCHAR, telefone VARCHAR, telemovel VARCHAR, id_tipo_meio VARCHAR);DROP TABLE IF EXISTS Event;CREATE TABLE Event (nic VARCHAR PRIMARY KEY  NOT NULL , subject VARCHAR, location VARCHAR, participants VARCHAR, startDate VARCHAR, endDate VARCHAR);";
              if (sqlite3_exec(database, sql_stmt, NULL, NULL, &amp;errMsg)
              != SQLITE_OK)
              {
                  isSuccess = NO;
                  NSLog(@"Failed to create tables");
              }
              sqlite3_close(database);
              return  isSuccess;
          }
          else {
              isSuccess = NO;
              NSLog(@"Failed to open/create database");
          }
      }
      return isSuccess;
  }
  </code></pre>