尝试打开SQLite3数据库时出错 我在VisualStudio社区2017中工作,我正在尝试打开并读取C++中的数据库信息。 #include <stdio.h> #include <string> using std::string; #include <sstream> using std::stringstream; #include "C:\Users\santiago.corso\Desktop\sqlite-amalgamation-3240000 (1)\sqlite-amalgamation-3240000\sqlite3.h" bool find_employee(int _id) { bool found = false; sqlite3* db; sqlite3_stmt* stmt; stringstream ss; // create sql statement string // if _id is not 0, search for id, otherwise print all IDs if (_id) { ss << "select * from employees where id = " << _id << ";"; } else { ss << "select * from employees;"; } string sql(ss.str()); //the resulting sql statement printf("sql: %s\n", sql.c_str()); //get link to database object if (sqlite3_open("C:\ProgramData\PROISER\ISASPSUS\datastore\dsfile.db", &db) != SQLITE_OK) { printf("ERROR: can't open database: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); return found; } // compile sql statement to binary if (sqlite3_prepare_v2(db, sql.c_str(), -1, &stmt, NULL) != SQLITE_OK) { printf("ERROR: while compiling sql: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); sqlite3_finalize(stmt); return found; } // execute sql statement, and while there are rows returned, print ID int ret_code = 0; while ((ret_code = sqlite3_step(stmt)) == SQLITE_ROW) { printf("TEST: ID = %d\n", sqlite3_column_int(stmt, 0)); found = true; } if (ret_code != SQLITE_DONE) { //this error handling could be done better, but it works printf("ERROR: while performing sql: %s\n", sqlite3_errmsg(db)); printf("ret_code = %d\n", ret_code); } printf("entry %s\n", found ? "found" : "not found"); //release resources sqlite3_finalize(stmt); sqlite3_close(db); return found; }

尝试打开SQLite3数据库时出错 我在VisualStudio社区2017中工作,我正在尝试打开并读取C++中的数据库信息。 #include <stdio.h> #include <string> using std::string; #include <sstream> using std::stringstream; #include "C:\Users\santiago.corso\Desktop\sqlite-amalgamation-3240000 (1)\sqlite-amalgamation-3240000\sqlite3.h" bool find_employee(int _id) { bool found = false; sqlite3* db; sqlite3_stmt* stmt; stringstream ss; // create sql statement string // if _id is not 0, search for id, otherwise print all IDs if (_id) { ss << "select * from employees where id = " << _id << ";"; } else { ss << "select * from employees;"; } string sql(ss.str()); //the resulting sql statement printf("sql: %s\n", sql.c_str()); //get link to database object if (sqlite3_open("C:\ProgramData\PROISER\ISASPSUS\datastore\dsfile.db", &db) != SQLITE_OK) { printf("ERROR: can't open database: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); return found; } // compile sql statement to binary if (sqlite3_prepare_v2(db, sql.c_str(), -1, &stmt, NULL) != SQLITE_OK) { printf("ERROR: while compiling sql: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); sqlite3_finalize(stmt); return found; } // execute sql statement, and while there are rows returned, print ID int ret_code = 0; while ((ret_code = sqlite3_step(stmt)) == SQLITE_ROW) { printf("TEST: ID = %d\n", sqlite3_column_int(stmt, 0)); found = true; } if (ret_code != SQLITE_DONE) { //this error handling could be done better, but it works printf("ERROR: while performing sql: %s\n", sqlite3_errmsg(db)); printf("ret_code = %d\n", ret_code); } printf("entry %s\n", found ? "found" : "not found"); //release resources sqlite3_finalize(stmt); sqlite3_close(db); return found; },c++,visual-c++,sqlite,C++,Visual C++,Sqlite,返回的错误来自类别编译器错误C4129 我找不到解决办法。如果您能帮助我,我将不胜感激。我可以通过在sqlite3\u中打开路径的所有部分来纠正上述错误。除此之外,还出现了另一个关于必须定义的入口点的错误,参考 if (sqlite3_open("C:\ProgramData\PROISER\ISASPSUS\datastore\dsfile.db", &db) != SQLITE_OK) { printf("ERROR: can't open database: %s\

返回的错误来自类别编译器错误C4129


我找不到解决办法。如果您能帮助我,我将不胜感激。

我可以通过在sqlite3\u中打开路径的所有部分来纠正上述错误。除此之外,还出现了另一个关于必须定义的入口点的错误,参考

if (sqlite3_open("C:\ProgramData\PROISER\ISASPSUS\datastore\dsfile.db", &db) != SQLITE_OK) {
        printf("ERROR: can't open database: %s\n", sqlite3_errmsg(db));
        sqlite3_close(db);
        return found;`
我还想知道的是,使用这段代码是否足以打开和读取数据库。我从sqlite3开始,接下来要做的是将其内容导出到excel文件。
有人建议我使用确切的应用程序,因为它是sqlite3固有的,类似于cmd。但是,我宁愿为此构建一个脚本,而不是使用cmd。

请从“输出”选项卡复制确切的错误消息,并将其作为文本粘贴到您的问题中。很少有读者会通过内存知道什么是C4129错误。。我的意思是“输出”选项卡而不是“错误列表”。包括确切的错误消息会有所帮助。您应该从路径中退出。实际上,这就是问题所在C4129是关于不正确转义序列的警告。。文档中甚至提到了修复程序:C:\ProgramData\PROISER\Isapsus\datastore\dsfile.db-使用前斜杠或双反斜杠。永远,永远,永远不要在includes中使用绝对路径!它们将阻止代码在任何非您自己的PC上正确编译!即使在你自己的电脑上,只要你重命名或移动路径中的某些目录,它也会失败