우리는 iPad 프로젝트에 SQLite를 사용하고 있습니다. 다른 SQLite에서 데이터를 가져오고 있습니다. 데이터를 가져온 후에는 viewcontroller에서 Sqlite로 다시 데이터를 삽입 할 수 없습니다. 동일한 장치에 액세스하려고 시도하면 오류가 발생하지만 시뮬레이터에서는 문제없이 작동합니다.Sqlite3에 데이터 가져 오기
Error from Device: * Assertion failure in -[DataBaseSharedManager insertLoginDetails:], /Users/vidya/Desktop/eDetail_feb27/eDetail/Classs/Database files/DataBaseSharedManager.m:165 Feb 27 18:07:17 unknown eDetail[1866] : Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error:failed to save priority with message 'database disk image is malformed'' ** First throw call stack: (0x33e758bf 0x352901e5 0x33e757b9 0x3289f3b3 0x336b15 0xae887 0x33dd422b 0x32fd8b 0x328fcc39 0x328546e9 0x328546b3 0x328545d5 0x375048a5 0x374f9545 0x374f9639 0x374f9243 0x374f9179 0x33e49b03 0x33e492cf 0x33e48075 0x33dcb4dd 0x33dcb3a5 0x306b6fcd 0x32393743 0xab125 0xab0bc)
참고 : SQlite 파일은 36MB입니다. 참조
코드 : 트랜잭션
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"eTest.sqlite"];
if (sqlite3_open([writableDBPath UTF8String], &database) == SQLITE_OK){
NSString *sSqlSelect = [NSString stringWithFormat:@"Insert into LOGIN (LoginId, UserName, Password, LastSyncDate, SFId,SecurityToken, AccountType, SFUserId,Region,ModifiedDate) values (\"%@\", \"%@\", \"%@\", \"%@\", \"%@\", \"%@\", \"%@\", \"%@\", \"%@\", \"%@\")", [pDict objectForKey:@"LoginId"],[pDict objectForKey:@"UserName"],[pDict objectForKey:@"Password"],[pDict objectForKey:@"LastSyncDate"],[pDict objectForKey:@"SFId"],[pDict objectForKey:@"SecurityToken"], [pDict objectForKey:@"AccountType"], [pDict objectForKey:@"SFUserId"],[pDict objectForKey:@"Region"],[pDict objectForKey:@"ModifiedDate"]];
sqlite3_stmt *insertValue;
int nResult = sqlite3_prepare_v2(database, [sSqlSelect UTF8String],-1,&insertValue,NULL);
if(nResult == SQLITE_OK){
sqlite3_step(insertValue);
}else{
NSAssert1(0,@"Error:failed to save priority with message '%s'",sqlite3_errmsg(database));
}
sqlite3_finalize(insertValue);
}else{
sqlite3_close(database);
NSAssert1(0, @"Failed to open database with message '%s'.", sqlite3_errmsg(database));
}
: 우리는 하나 SQLite는의 데이터를 내보내고 다른 SQLite는에 동일한 테이블을 가져. 우리는 이것을 위해 Firefox SQLite Manager를 사용하고 있습니다.
위의 질문에 대한 해결책 찾기에서 도움주세요. –
어떤 줄이 예외인지 알 수 있습니까? – NSCry
NSAssert1 (0, @ " '% s'메시지로 데이터베이스를 열지 못했습니다.", sqlite3_errmsg (database)); – Deepthi