我们正在为我们的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进行此操作。
请帮助我们找到上述问题的解决方案.. – 2012-02-27 12:42:37
你能告诉哪一行它是异常吗? – NSCry 2012-02-27 14:01:18
NSAssert1(0,@“无法用消息'%s'打开数据库。”,sqlite3_errmsg(database)); – Deepthi 2012-02-27 14:03:31