What was the problem? I am also stuck in the same problem from the past three days. I want to insert data in sqlite database, but not getting success.
I am writing these lines of code
-(void) addNewRecordsbyUserName

NSString *)_userName withCountryName

NSString *)_countryName andEmail

NSString *)_emailAddress{
@try
{
NSFileManager *fileManager=[NSFileManager defaultManager];
NSString *theDBPath=[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"Database.sqlite"];
BOOL success=[fileManager fileExistsAtPath:theDBPath];
(sqlite3_open([theDBPath UTF8String], &database))
{
NSString *query = [[NSString alloc ] initWithFormat:@"insert into userinformation Values(%d,'%@','%@','%@')",idName,_emailAddress,_c ountryName,_userName];
const char *sql = [query UTF8String];
sqlite3_stmt *statement;
sqlite3_prepare_v2(database, sql,-1,&statement,NULL)
sqlite3_bind_text(statement, 1, [_userName UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(statement, 2, [_emailAddress UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(statement, 3, [_countryName UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_int(statement,4,4); [query release];
sqlite3_finalize(statement)
sqlite3_close(database)
}
@catch (NSException * e)
{
NSLog(@"An exception occured:%a",[e reason]);
}
}
I have no idea where i am putting mistake. Can anybody please help me here. Looking for your positive responses in a very quick time as i am in very much hurry.