I have an application concists of uitextview (self.animalDesciption) , and button
I use the button to update database with the text in the uitextview
but it always give EXC_BAD_ACCESS at the line
NSString *NewData = [NSString stringWithFormat:@”%@%@%@%@”, @”Update animals set description = “,TheNewText , ” Where name = “,the_user];
the full code is
sqlite3 *database;
// Setup some globals
NSString *databaseName = @"test.sql";
// Get the path to the documents directory and append the databaseName
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
NSString * databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
[databasePath retain];
sqlite3_stmt *compiledStatement;
NSString * TheNewText = self.animalDesciption.text;
[TheNewText retain];
NSString * the_user = AnimalName ;
[ the_user retain];
NSString *NewData = [NSString stringWithFormat:@"%@%@%@%@", @"Update animals set description = ",TheNewText , " Where name = ",the_user];
[NewData retain] ;
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
const char *sqlStatement = [NewData UTF8String];
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL)== SQLITE_OK) {
sqlite3_reset(sqlStatement);
}
any suggestion please
Best regards
Try:
NSString *NewData = [NSString stringWithFormat:@"%@%@%@%@", @"Update animals set description = ",TheNewText , @" Where name = ",the_user];Note the @”Where name = “