Sqlite3: cannot be closed due to pending statements

I have two sqlite connections and are executed as shown below (CMyDatabase is a sqlite3 derived class):

CMyDatabase* dbConnection1 = new CMyDatabase;
dbConnection1->OpenDataBase(CQCommon::GetModulePath() + L"test.db");

CMyDatabase* dbConnection2 = new CMyDatabase;
dbConnection2->OpenDataBase(CQCommon::GetModulePath() + L"test.db");

dbConnection2->BeginTrans();
CString updateStr("update ImageAlbumEntry set ImageID = 2 where ID = 1;");
dbConnection2->ExecNoQuery(updateStr);
CString queryStr("select ImageID from ImageAlbumEntry where ID = 1;");
CppSQLite3Query queryResult;
dbConnection2->ExecQuery(queryStr, queryResult);
cout<<queryResult.getIntField(0)<<endl;
dbConnection2->EndTrans(TRUE);

dbConnection2->CloseDataBase();
dbConnection1->CloseDataBase();

Now when I call dbConnection1-> CloseDataBase (). I met with an error declared as "Failed to close due to pending statements." Can someone explain the reason and solve the problem? Thanks!

+3
source share
1 answer

Depends on which shell you are using. I assume you are using one similar to cppSQLite3

, CppSQLite3Query:: finalize, sqlite3, .

sqlite3

sqlite3_finalize()
, sqlite3_prepare(). , .

+6

All Articles