2014-10-29 35 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)行可能會導致問題,因爲它可能永遠不會得到真正的和查詢您的越來越零值。請嘗試更改條件或評論它。現在

相關問題