我的代码是
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){
我将数据插入名为Student的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 :(得分:0)
if(self.recordIDToEdit == -1)行可能导致问题,因为它可能永远不会变为真,并且您的查询值为nil。尝试改变条件或评论它。