c++ - Why is this SQlite3 query execution returning "SQLITE BUSY : Database is locked" and what it the likely solution -


this code keeps returning "sqlite busy : database locked" though not accessing external thread or process , how can resolve this?

the code uses cppsqlite3 c++ wrapper sqlite.

int departmentaccess::saveordeleteaccess(long long ideptnameid,long long &iuserid,int &iaccesstypeid) {     char szstring[1000];     char chaccesstypeid[1000];      stringcbprintfa(szstring,sizeof(szstring),"%d",iaccesstypeid);     encryptstring(szstring,chaccesstypeid);       try     {         char szdatabasefile[1000];         getdatabasea(szdatabasefile,sizeof(szdatabasefile));          cppsqlite3db db;         db.open(szdatabasefile);          cppsqlite3statement stmt = db.compilestatement("select accessid departmentaccess (insututionid = ? , deptnameid = ? , userid = ? , accesstype = ?)");         stmt.bind(1,m_iinsututionid);         stmt.bind(2,ideptnameid);         stmt.bind(3,iuserid);         stmt.bind(4,chaccesstypeid);         cppsqlite3query q = stmt.execquery();         if(!q.fieldisnull(0))         {             if(!m_imode)             {                 return -2;             }         }          if(!m_imode)         {             stringcbcopya(szstring,sizeof(szstring),"insert departmentaccess(insututionid,deptnameid,userid,accesstype) values(?,?,?,?)");         }         else         {             stringcbcopya(szstring,sizeof(szstring),"delete departmentaccess (insututionid = ? , deptnameid = ? , userid = ? , accesstype = ?)");         }          cppsqlite3statement stmt1 = db.compilestatement(szstring);          int iposition = 1;          stmt1.bind(iposition++, m_iinsututionid);         stmt1.bind(iposition++, ideptnameid);         stmt1.bind(iposition++, iuserid);         stmt1.bind(iposition++, chaccesstypeid);         //execution gets point         stmt1.execdml();         //execution fails point         if(!m_imode)         {             stringcbprintfa(szstring,sizeof(szstring),"delete departmentaccessrequest (insututionid = ? , deptnameid = ? , userid = ? , requestedaccess = ?)");             cppsqlite3statement stmt2 = db.compilestatement(szstring);             int iposition = 1;              stmt2.bind(iposition++, m_iinsututionid);             stmt2.bind(iposition++, ideptnameid);             stmt2.bind(iposition++, iuserid);             stmt2.bind(iposition++, chaccesstypeid);              stmt2.execdml();         }         return 1;     }     catch(cppsqlite3exception & e)     {         char szstring[200];         stringcbprintfa(szstring,sizeof(szstring),"error code: %d\n error mesage: %s",e.errorcode(),e.errormessage());         messageboxa(null,szstring,"save or delete access error(department access)",mb_ok);     }      return 0; } 


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -