c++ - 在 Visual Studio 2017 中构建程序时出错
问题描述
关于必须定义的入口点弹出错误,指
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;`
我正在使用带有 c++/sqlite3 库的 Visual Studio Community 2017。
这是整个代码:
#include <stdio.h>
#include <string>
using std::string;
#include <sstream>
using std::stringstream;
using namespace std;
#include "C:\\Users\\santiago.corso\\Desktop\\sqlite-amalgamation-3240000 (1)\\sqlite-amalgamation-3240000\\sqlite3.h"
bool find_analysis(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
// this can also be achieved with the default sqlite3_bind* utilities
if (_id) { ss << "select * from analysis where id = " << _id << ";"; }
else { ss << "select * from analysis;"; }
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;
}
该程序的全部目的是读取数据库中的更改作为第一部分。第二部分,将更改导出到 excel 文件(我还没有从这部分开始)。
在另一部分,我正在其他 .cpp 中构建相同的程序,它会做同样的事情,但以另一种方式编写。我在这段代码中有一部分的工作是寻找文件的结尾并从那里开始阅读:
void recordarposicion(){
int feof;
if (fseek(dsfile, 0L, SEEK_END)==feof)
printf("%i = fread(dsfile)" );
}
解决方案
推荐阅读
- c# - 从 Blazor (wasm) 调用 gRPC 时忽略证书错误
- django - 如何过滤foreign_key表单的列表并更改Django admin中的显示名称?
- java - 尝试将数据添加到 Firebase 时出现 @Override、getException 和 @NonNull 的 Android Studio 错误 - 我需要准确的代码吗?
- jenkins - 如何在 Jenkins 中运行 cppcheck?
- swift - NSExpresseion,确定从左关联操作
- java - 如何解决实时数据库应用程序中的表元数据锁定
- swiftui - SwiftUI, 'Fatal error: Unexpectedly found nil while unwrapping an Optional value' message
- python - 在微观时间范围内捕捉峰值/趋势结束的最佳方法?
- c# - 使用 gdiplus 打印 png24 图像时 GDI 内存泄漏
- cmake - 如何组织 ctest 测试夹具