1

I am testing a simple C++ SQLite piece of code:

sqlite3* db;
if (sqlite3_open("SteelTable.db", &db) != SQLITE_OK) { 
    sqlite3_close(db);
    return 0;
}

std::string createQuery = "CREATE TABLE WFPROFILE ("
    "ID   INT PRIMARY KEY     NOT NULL,"
    "D    REAL    NOT NULL,"
    "WT   REAL    NOT NULL,"
    "WB   REAL    NOT NULL,"
    "TF   REAL    NOT NULL,"
    "TB   REAL    NOT NULL);";

sqlite3_stmt* createStmt;
sqlite3_prepare(db, createQuery.c_str(), static_cast<int>(createQuery.size()), &createStmt, nullptr);
if (sqlite3_step(createStmt) != SQLITE_DONE) {
    sqlite3_close(db);
    return 0;
}

std::vector<std::string> sqlStmList;
sqlStmList.emplace_back("INSERT INTO WFPROFILE ('ID','D','WT','WB','TF','TB') VALUES ('1','20','10','15','1','1.5');");
sqlStmList.emplace_back("INSERT INTO WFPROFILE ('ID','D','WT','WB','TF','TB') VALUES ('2','25','12','17','2.5','2');");
sqlStmList.emplace_back("INSERT INTO WFPROFILE ('ID','D','WT','WB','TF','TB') VALUES ('3','30','14','19.5','2.5','2.5');");

for (const auto& insertQuery : sqlStmList) {
    sqlite3_stmt* insertStmt;
    sqlite3_prepare(db, insertQuery.c_str(), static_cast<int>(insertQuery.size()), &insertStmt, nullptr);
    if (sqlite3_step(insertStmt) != SQLITE_DONE) {
        sqlite3_close(db);
        return 0;
    }
    
}

sqlite3_close(db);

This runs fine in a console executable, but gives a weird run time exception (at the CREATE TABLE statement) when the same code is part of ObjectARX C++ for AutoCAD. enter image description here

Has anyone encountered this before or does anyone know how to fix it. Any pointers would be highly appreciated. Thanks

sidb
  • 11
  • 2

0 Answers0