我不知道我的程序中有什麼問題。Sqlite數據庫文件正在加密或不是數據庫
kill error while killing target (killing anyway):
warning: error on line 2179 of "/SourceCache/gdb/gdb-1510/src/gdb/macosx/macosx-nat-inferior.c" in function "macosx_kill_inferior_safe": (os/kern) failure (0x5x)
quit
這裏是我的插入代碼:
-(id)init {
self = [super init];
sqlite3 *database;
NSMutableArray *locations;
NSString *result = nil;
NSString *dbPath = [self getWritableDBPath];
if(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK)
{
NSString *sqlStr = [NSString stringWithFormat:@"select Longitude,Latitude from myLocation"];
const char *sqlStatement = [sqlStr UTF8String];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
locations = [NSMutableArray array];
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
double longitude = sqlite3_column_double(compiledStatement, 0);
double latitude = sqlite3_column_double(compiledStatement, 1);
NSLog(@"%f , %f",longitude,latitude);
NSString *coords = [[[NSString alloc] initWithFormat:@"%f,%f\n",longitude,latitude] autorelease];
[locations addObject:coords];
NSLog(@"this location :-%@",locations);
//[coords release];
}
result = [locations componentsJoinedByString:@","]; // same as `fake_location`
NSLog(@"this for resulte data :- %@",result);
// Get file path here
NSError *error;
if ([result writeToFile:dbPath atomically:YES encoding:NSUTF8StringEncoding error:&error]) {
NSLog(@"%@", [error localizedDescription]);
}
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
pointsArray = [[result componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] retain];
pointsArrayIndex = 0;
oldLocationsIndex = 0;
[result release];
oldLocations = [[NSMutableArray alloc] init];
return self;
}
第二次,我跑我的應用程序時,在我的程序從SQlite的獲取數據運行此選擇的代碼,它第一次與此錯誤消息崩潰,它顯示我在控制檯上:
Save Error: file is encrypted or is not a database
這些錯誤是什麼意思,我該如何解決?
你想火插入查詢的sqlite的????? – iMOBDEV
是的我的朋友我需要的sqlite插入語句 – Ajay
你試圖用NSData覆蓋整個數據庫文件,你不能這樣做,檢查我的答案在下面,你只需要引發插入查詢... – iMOBDEV