我得到 exc_bad_access 代码=2。有时它的工作没有错误,但有时它会出错。我不知道为什么会这样。如果有人发现任何问题,请告诉我这是我的代码..
if (sqlite3_open(dbpath, &adhDB) == SQLITE_OK)
{
sqlite3_stmt *compiledStatement;
const char *sqlStatement = "INSERT INTO tblNotifications (NotificationID,Description,BeforeHrs,AfterHrs,PreparationID,PreparationName,ProcedureID,ProcedureName,ClientID,IsActive,UpdatedDateTime) VALUES (?,?,?,?,?,?,?,?,?,?,?)"; // Total 11 ?
NSLog(@"sqlStatement = %s",sqlStatement);
if(sqlite3_prepare_v2(adhDB, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK)
{
int i = 0;
for (statusNotification in nsNotification)
{
NSString *NotificationID1 =[statusNotification objectForKey:@"NotificationID"];
NotificationID1 = [NotificationID1 stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSString *Description1 = [statusNotification objectForKey:@"Description"];
Description1 = [Description1 stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSString *BeforeHrs1 = [statusNotification objectForKey:@"BeforeHrs"];
BeforeHrs1 = [BeforeHrs1 stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSString *AfterHrs1 = [statusNotification objectForKey:@"AfterHrs"];
AfterHrs1 = [AfterHrs1 stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSString *PreparationID1 =[statusNotification objectForKey:@"PreparationID"];
PreparationID1 = [PreparationID1 stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSString *PreparationName1 =[statusNotification objectForKey:@"PreparationName"];
PreparationName1 = [PreparationName1 stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSString *ProcedureID1 =[statusNotification objectForKey:@"ProcedureID"];
ProcedureID1 = [ProcedureID1 stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSString *ProcedureName1 =[statusNotification objectForKey:@"ProcedureName"];
ProcedureName1 = [ProcedureName1 stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSString *ClientID1 =[statusNotification objectForKey:@"ClientID"];
ClientID1 = [ClientID1 stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSString *IsActive1 =[statusNotification objectForKey:@"IsActive"];
IsActive1 = [IsActive1 stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSString *UpdatedDateTime1 = [HomeScreen returnDateTime];
sqlite3_bind_text(compiledStatement, 1, [NotificationID1 UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 2, [Description1 UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 3, [BeforeHrs1 UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 4, [AfterHrs1 UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 5, [PreparationID1 UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 6, [PreparationName1 UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 7, [ProcedureID1 UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 8, [ProcedureName1 UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 9, [ClientID1 UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 10, [IsActive1 UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 11, [UpdatedDateTime1 UTF8String], -1, SQLITE_TRANSIENT);
// NSLog(@"UpdatedDateTime= %@",UpdatedDateTime1);
if (sqlite3_step(compiledStatement) == SQLITE_DONE) {
if (i == cntProcedures)
sqlite3_finalize(compiledStatement);
else
sqlite3_reset(compiledStatement);
}
else {
}
i++;
}
}
}
提前致谢。