Hi Devi,

Please try this code for creating a table and inserting the records
into the SQLite table:

- (void)createCountryTableIfNeeded {
        @synchronized(self)
{
         sqlite3_stmt *create_statement = nil;
static char *sql = "CREATE TABLE IF NOT EXISTS tb_countries (id
INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, sname  VARCHAR2(100))";
                if (sqlite3_prepare_v2(database, sql, -1, &create_statement,
NULL) != SQLITE_OK) {
NSAssert1(0, @"Error: failed to prepare statement with message '%s'.",
sqlite3_errmsg(database));
                  }
  int success = sqlite3_step(create_statement);
  sqlite3_finalize(create_statement);
  if (success == SQLITE_ERROR) {
   NSAssert1(0, @"Error: failed to create mobclix table with message
'%s'.",     sqlite3_errmsg(database));
                }
        }
}

- (void)saveCountries:(NSString *)sname {
@synchronized(self) {
  sqlite3_stmt *insert_statement = nil;
  static char *sql = "INSERT INTO tb_countries (sname) VALUES (?)";
  if (sqlite3_prepare_v2(database, sql, -1, &insert_statement, NULL) !
= SQLITE_OK) {
 NSAssert1(0, @"Error: failed to prepare statement with message
'%s'.",   sqlite3_errmsg(database));
                }
 sqlite3_bind_text(insert_statement, 1, [sname UTF8String], -1,
SQLITE_TRANSIENT);
 int success = sqlite3_step(insert_statement);
 sqlite3_finalize(insert_statement);
 if (success == SQLITE_ERROR) {
 NSAssert1(0, @"Error: failed to start new mobclix with message
'%s'.", sqlite3_errmsg(database));
                }
 }
}


Hope that helps.

Sutikshan,
www.netsolutionsindia.com | we build custom iphone apps

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to