Possible Duplicate:
Assertion failure error in objective c
I want to try insert some data in to sqlite database table but I got an error like this:
***Assertion failure in -[ViewController buttonClick:],/Users/ds/Desktop/SqliteDeneme/SqliteDeneme/ViewController.m:57
My code is here:
- (IBAction)buttonClick:(id)sender {
NSString *str1 =@"1";
NSString *str2 =@"1";
NSString *str3 =@"0.1";
NSString *str4 =@"0.1";
NSString *str5 =@"0.1";
NSString *str6 =@"0.1";
NSString *str7 =@"deneme";
NSString *str8 =@"1";
NSString *str9 =@"1";
NSString *str10=@"deneme";
NSArray *pathsArray=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *doumentDirectoryPath=[pathsArray objectAtIndex:0];
destinationPath=[doumentDirectoryPath stringByAppendingPathComponent:@"SqliteTestDb.sqlite"];
NSLog(@"database path %@",destinationPath);
if (sqlite3_open([destinationPath UTF8String], &cruddb)==SQLITE_OK)
{
NSLog(@"dataBaseOpen");
// leak happens here, do stuff then call sqlite3_close(database), or move it out of the if/else block.
if(stmt == nil) {
const char *sql = "INSERT INTO LabUpdate (IsSuccess, ProducerId, Latitude, Longitude, Altitude, Slope, SampleDate, PackageNo, Status, Description) VALUES (?,?,?,?,?,?,?,?,?,?)";
if(sqlite3_prepare_v2(cruddb, sql, -1, &stmt, NULL) == SQLITE_OK){
//sqlite3_prepare_v2(cruddb, sql, 1, &stmt, NULL);
sqlite3_bind_int(stmt, 1, [str1 integerValue]);
sqlite3_bind_int(stmt, 2, [str2 integerValue]);
sqlite3_bind_double(stmt, 3, [str3 floatValue]);
sqlite3_bind_double(stmt, 4, [str4 floatValue]);
sqlite3_bind_double(stmt, 5, [str5 floatValue]);
sqlite3_bind_double(stmt, 6, [str6 floatValue]);
sqlite3_bind_text(stmt, 7, [str7 UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_int(stmt, 8, [str8 integerValue]);
sqlite3_bind_int(stmt, 9, [str9 integerValue]);
sqlite3_bind_text(stmt, 10, [str10 UTF8String], -1, SQLITE_TRANSIENT);
}
else
NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(cruddb));
}
if(SQLITE_DONE != sqlite3_step(stmt))
NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(cruddb));
else
//SQLite provides a method to get the last primary key inserted by using sqlite3_last_insert_rowid
recordID = sqlite3_last_insert_rowid(cruddb);
//Reset the add statement.
sqlite3_reset(stmt);
}
else {
sqlite3_close(cruddb);
NSLog(@"dataBaseNotOpen");
NSAssert1(0, @"Error while opening database '%s'", sqlite3_errmsg(cruddb));
}
}
How can I solve this problem? I put a breakpoint and I saw it is not entered after this line:
if(sqlite3_prepare_v2(cruddb, sql, -1, &stmt, NULL) == SQLITE_OK){
this is my database table and colums: