我正在用c ++开发一个应用程序,但是当程序到达sqlite3_prepare_v2
语句时出现错误
这是代码,非常感谢您的帮助!
int Database::save_lesson (Lesson *lesson) {
int id ;
std::ostringstream oss ;
oss << "insert into lesson (name, teacher, place, begin, end)" ;
oss << "values ( " ;
oss << "'" << lesson->get_name() << "', " ;
oss << "'" << lesson->get_teacher() << "', " ;
oss << "'" << lesson->get_slots() << "', " ;
oss << "'" << lesson->get_begin() << "', " ;
oss << "'" << lesson->get_end() << "') ;" ;
check (sqlite3_prepare_v2 (
db,
oss.str().c_str(),
-1,
&stmt,
0)
) ;
sqlite3_step(stmt) ;
sqlite3_finalize(stmt) ;
oss.clear();
oss.str("");
oss << "select max(id) from lesson ;" ;
// error occured here:
check (sqlite3_prepare_v2 (
db,
oss.str().c_str(),
-1,
&stmt,
0)
) ;
sqlite3_step(stmt) ;
id = sqlite3_column_int(stmt, 0) ;
sqlite3_finalize(stmt) ;
return id ;
}
修改
错误消息为:bad parameter or other API misuse
(非常有用)