我想在我的c ++ - Code中使用SQLite,所以我包含了SQLite3。当我在外部* .exe中使用以下代码时,它没有任何问题:
void create_Database(char * file_name)
{
std::ofstream debug("C:\\Users\\Roland-User\\Desktop\\Debug.txt");
//const std::string&filename = file_name;
std::string filename = "C:\\Users\\Roland-User\\Desktop\\data";
std::string appendix = ".database";
std::string file = filename + appendix;
debug << "Creating database\n";
sqlite3 *db;
char *zErrMsg = 0;
int rc;
char * sql;
rc = sqlite3_open(file.c_str(), &db);
if(rc)
exit(-1);
sql = "CREATE TABLE DATABASE(HEADERDATA INT, WAVENUMBER INT, POSX INT, POSY INT, COUNT INT);";
rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
if(rc == 1)
{
sql = "DROP DATABASE DATABASE;";
rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
sqlite3_free(zErrMsg);
sql = "DROP TABLE DATABASE;";
rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
sqlite3_free(zErrMsg);
debug << "Having to drop database!\n";
};
sql = "CREATE TABLE DATABASE(HEADERDATA INT, WAVENUMBER INT, POSX INT, POSY INT, COUNT INT);";
rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
if(rc!=SQLITE_OK)
{
debug << "Still there are errors, I am confused!\n";
debug << "With error codes: " << rc << '\n';
sqlite3_free(zErrMsg);
exit(-1);
};
debug << "Finished with creating database\n";
debug.close();
sqlite3_close(db);
};
但是当我在DLL中插入这段代码时,我的第二次检查总是出错(我得到调试信息:“有错误代码:”)。我总是得到错误代码1.我怎么能解决这个问题,我做错了什么? 非常感谢你!