jeudi 5 novembre 2015

SQLite3 "out of memory" error when initializing database

My code just gone weird. It was working fine, when I tried deleting the database file to restart from the beginning, then I've received an "out of memory" message at each query. But the initializing is fine.

Here is my function's code:

#include "sqlite3.h"
#include <cstdlib>
#include "pmsg.h"

sqlite3* getCon(string fileName)
{
sqlite3 *db;
int connRes;
connRes = sqlite3_open_v2(fileName.c_str(),&db,SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,NULL);
if(connRes == SQLITE_OK) //True initialization's fine. 
{
    pmsg((string)"Database succefully connected", 0);
} else {

pmsg((string)"Fatal error connecting db !", 1);
exit(1);

}
char* zErrMsg;
sqlite3_exec(db,"SELECT * FROM Course;",NULL,NULL,&zErrMsg); //zErrMsg change to "out of memory"
return db;
}

Thank you :)

Aucun commentaire:

Enregistrer un commentaire