I want to perform a simple query (drop table) with sqlite native interface and I persistently run into SQLITE_ERROR as I try to prepare the statement. I tried everything as I was afraid of string compatibility (qt strings can be a pain sometimes) but every it always gives me the same the code is the following:
sqlite3_stmt *query;
std::string tmp = "DROP TABLE ?";
if(sqlite3_prepare_v2(db, tmp.c_str(), tmp.size(), &query, NULL) != SQLITE_OK)return FALSE;
if(sqlite3_bind_text16(query, 1, str.utf16(), -1, SQLITE_TRANSIENT) != SQLITE_OK) return FALSE;
if(sqlite3_step(query) != SQLITE_OK) {
std::cerr << sqlite3_errmsg(db);
return FALSE;
}
sqlite3_finalize(query);
I hope sincerely someone out there can help.
You can’t pass table names as parameters (it applies to most database APIs supporting parameters, maybe even all database APIs).