2011-09-05 58 views
0

我試圖在iPhone和所有其他工作的插入語句,但我嘗試這一個,之後,我嘗試綁定值,但我得到錯誤21,似乎是因爲stmt變量發生後準備爲0x00(空我認爲) 但不知道什麼會發生iPhone的SQLite準備錯誤

sqlite3 *database; 
     sqlite3_open([pathDb UTF8String], &database);   
     sqlite3_stmt *stmt; 

     NSString *insert = @""; 
     if ([model.ident intValue] != -1) 
     { 
      insert = @"UPDATE Blubb SET Key=? WHERE Id = ?"; 
     } 
     else 
     { 
      insert = @"INSERT INTO Blubb (Id, Field,KeyLastUpdate,SortNr) VALUES (?,NULL,date('now'), SELECT COUNT(*) + 1 FROM Connections)"; 
     } 
     const char *insertStmt = [insert UTF8String]; 


     int result = sqlite3_prepare(database, insertStmt, -1, &stmt, NULL); 

回答