gpt4 book ai didi

iphone - iPhone 和 sqlite 查询的问题

转载 作者:行者123 更新时间:2023-12-03 19:06:46 24 4
gpt4 key购买 nike

当我尝试运行我的程序时出现以下错误。我得到它的任何理由?我已经尝试了几个小时,但我放弃了。谢谢!

错误:

2011-03-08 19:18:29.967 iphoneApp[2561:207] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“* +[NSString stringWithUTF8String:]: NULL cString'

- (AnswerDTO *)findAnswerById:(NSInteger)primary_key {
AnswerDTO *dto = [[[AnswerDTO alloc] init] autorelease];

sqlite3_stmt *statement = nil;
const char *sql = "SELECT * FROM klb_answers WHERE id = 7;";

if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
sqlite3_bind_int(statement, 1, primary_key);

NSInteger answerId = sqlite3_column_int(statement, ANSWER_ID);
NSInteger answerQuestionId = sqlite3_column_int(statement, ANSWER_QUESTION_ID);
NSString *answerDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, ANSWER_DESCRIPTION)];
NSString *answerSerialNumber = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, ANSWER_SERIAL_NUMBER)];
NSInteger answerIsCorrect = sqlite3_column_int(statement, ANSWER_IS_CORRECT);

dto.answerID = answerId;
dto.questionID = answerQuestionId;
dto.description = answerDescription;
dto.serialNumber = answerSerialNumber;

if (answerIsCorrect == 0) {
dto.isCorrect = NO;
} else {
dto.isCorrect = YES;
}
} else {
NSLog(@"Noe feil med statementet");
}

sqlite3_finalize(statement);

return dto;
}

最佳答案

看起来您并没有“运行”您的查询。你准备好了它并绑定(bind)了你的参数,但你从未运行 sqlite3_step() 来执行查询并获得响应。即使它是单个记录或标量。

因此,您的列函数返回空值。

关于iphone - iPhone 和 sqlite 查询的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5236626/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com