I am trying to insert values into new table added, my development app works fine whereas, my testing app its giving error SQLITE MISUSE when inserting data to new table, when i check the sqlite file it contains that table, but if i have app without login then try to login again, it works fine, i am not understanding why SQLITE MISUSE error, in this case update will not work.
Add Table :
createSQL = [NSString stringWithFormat:@"CREATE TABLE if not exists [%@] (id integer PRIMARY KEY AUTOINCREMENT, title text, description text, favourite text, template text, modified_date text)", NEW_TABLE];
if (sqlite3_exec (database, [createSQL UTF8String],NULL, NULL, &errorMsg) != SQLITE_OK)
{
sqlite3_close(database);
NSLog(@"Error in creating Inbox table: %s",errorMsg);
}
Insert :
sqlite3_stmt *stmt;
int sqlError;
NSString *query = [NSString stringWithFormat:@"INSERT INTO %@ (title, description, favourite, template, modified_date) values (?,?,?,?,?)", NEW_TABLE];
const char *zSql = [query UTF8String];
sqlError = sqlite3_prepare_v2(database, zSql, -1, &stmt, nil);
if (sqlError == SQLITE_OK) {
// insert data
} else {
DLog(@"Error - %d while preparing startement - %@", sqlError, query);
}
Aucun commentaire:
Enregistrer un commentaire