Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(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;
- }
- -(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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement