exc_bad_access code=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++;
}
}
}
前もって感謝します。