dimanche 19 avril 2015

iOS - Fail to update table?

My table is not uptading during insertion. Also not showing in tableview but after click add "New record" message comes with "Record is added" so there is no any errors


Insertion in a table function:



-(int) insert:(NSString *)filePath withBrand:(NSString *)brand
{
sqlite3* db = NULL;
int rc=0;
rc = sqlite3_open_v2([filePath cStringUsingEncoding:NSUTF8StringEncoding], &db, SQLITE_OPEN_READWRITE , NULL);
if (SQLITE_OK != rc)
{
sqlite3_close(db);
NSLog(@"Failed to open db connection");
}
else
{
NSString * query = [NSString
stringWithFormat:@"INSERT INTO brands (bikeBrandName) VALUES (?)"];
char * errMsg;
rc = sqlite3_exec(db, [query UTF8String] ,NULL,NULL,&errMsg);
if(SQLITE_OK != rc)
{
NSLog(@"Failed to insert record rc:%d, msg=%s",rc,errMsg);
}
sqlite3_close(db);
}
return rc;
}


Also tried this one:



-(int) insert:(NSString *)filePath withBrand:(NSString *)brand
{
sqlite3* db = NULL;
int rc=0;
rc = sqlite3_open_v2([filePath cStringUsingEncoding:NSUTF8StringEncoding], &db, SQLITE_OPEN_READWRITE , NULL);
if (SQLITE_OK != rc)
{
sqlite3_close(db);
NSLog(@"Failed to open db connection");
}
else
{
NSString * query = [NSString
stringWithFormat:@"INSERT INTO brands (bikeBrandName) VALUES (\"%@\")",brand];
char * errMsg;
rc = sqlite3_exec(db, [query UTF8String] ,NULL,NULL,&errMsg);
if(SQLITE_OK != rc)
{
NSLog(@"Failed to insert record rc:%d, msg=%s",rc,errMsg);
}
sqlite3_close(db);
}
return rc;
}

Aucun commentaire:

Enregistrer un commentaire