Это не работает. Когда я выполняю это, я получаю одно сообщение, EXC_BAD_ACCESS
.
-(void) adddata{
NSString *event=@"max";
NSString *venue=@"tvm";
NSString *edate=@"may 6";
NSString *etime=@"10:30";
int admts=5;
NSString *ima=@"TTTTTTTTT";//ticobj.iimg;
sqlite3 *database;
databaseName = @"smbhDB.sql";
sqlite3_stmt *addStatement=nil ;
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
const char *sql ="insert into tickets (admittance, venue, event, date, time, imagedata) Values (?,?,?,?,?,?)";
databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
if(sqlite3_prepare_v2(database, sql, -1, &addStatement, NULL) != SQLITE_OK)
NSAssert1(0, @"444 Error while creating add statement. '%s'", sqlite3_errmsg(database));
sqlite3_bind_int(addStatement,1,admts);
printf("\n\n inthe add ticket ");
sqlite3_bind_text(addStatement, 2, [venue UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(addStatement, 3, [event UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(addStatement, 4, [edate UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(addStatement, 5, [etime UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(addStatement, 6, [ima UTF8String], -1, SQLITE_TRANSIENT);
if(SQLITE_DONE != sqlite3_step(addStatement))
NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
sqlite3_reset(addStatement);