2014-10-29 23 views
1

我的代码是sqlite3的错误EXC_BAD_ACEES(代码= 2,地址= 0 * 0

sqlite3_stmt *compiledStatement; 

    // Load all data from database to memory. 
    BOOL prepareStatementResult = sqlite3_prepare_v2(sqlite3Database, query, -1, &compiledStatement, NULL); 
    if(prepareStatementResult == SQLITE_OK) { 
     // Check if the query is non-executable. 
     if (!queryExecutable){ 

和i。在Student.sql插入数据具有名称学生database.my表。 我的插入命令崩溃是

NSString *query; 
if (self.recordIDToEdit == -1) { 


query = [NSString stringWithFormat:@"insert into Student values(null, %d, '%@', %d,'%@')", [self.MobNoTxt.text intValue], self.UniTxt.text, [self.YearTxt.text intValue],self.BranchTxt.text]; 

    } 


[self.dbManager executeQuery:query]; 
if (self.dbManager.affectedRows != 0) { 
    NSLog(@"Query was executed successfully. Affected rows = %d", self.dbManager.affectedRows); 
} 
else{ 
    NSLog(@"Could not execute the query."); 
} 
+0

这个编码g很好,你需要验证create table方法是否正确 – 2014-10-29 07:30:25

回答

0

如果(self.recordIDToEdit == -1)行可能会导致问题,因为它可能永远不会得到真正的和查询您的越来越零值。请尝试更改条件或评论它。现在

相关问题