Greetings all, I imagine this has been covered before, but I've been through the archives and couldn't find what I needed. So I'm appealing to a larger authority.
I am writing some C++ objects to handle access to a database. Two of them are virtually identical: C_DAOService and C_DAOPerformer. To test these classes, I've written some scaffolding that simply reads, writes and deletes from the tables using these classes. The C_DAOService class works fine. It gives me no problems. But when I try to insert a row with the C_DAOPerformer class, I'm getting an "SQLITE_BUSY [5] database is locked" error. And I don't know why. I'm using SQLITE 3.0.7, and the CppSQLite3 wrapper code on a Windows XP home edition box. I've never had any problems before this. The C_DAOPerformer code in question is... bool C_DAOPerformer::PerformerModify( performerinfoStruct pi, bool exists ) { bool retVal = true; bool commitOn = false; char tempsrvc[30]; char *sqlinsert = "insert into performers ( active, useforfill, solosperqtr, ofersperqtr, preperqtr, postperqtr, performerid, fname, lname ) values ( ?, ?, ?, ?, ?, ?, ?, ?, ? )"; char *sqlupdate = "update performers set active = ?, useforfill = ?, solosperqtr = ?, ofersperqtr = ?, preperqtr = ?, postperqtr = ? where performerid = ?"; char *sqlnewsrvc = "insert into performswhen( srvcid, performerid ) values ( ?, ? )"; char *sqldelsrvc = "delete from performswhen where srvcid = ? and performerid = ?"; CppSQLite3DB db; try { CppSQLite3Statement stmt; cout << "C_DAOPerformer\tOpening Database\n"; db.open(MMHDB); /* cout << "C_DAOPerformer\tBeginning Transaction\n"; db.execDML("begin transaction"); commitOn = true; */ // ========================================== // Modify or insert a performer // ========================================== if ( exists ) { cout << "C_DAOPerformer\tCompiling Update Statement\n"; stmt = db.compileStatement(sqlupdate); } else { cout << "C_DAOPerformer\tCompiling Insert Statement\n"; stmt = db.compileStatement(sqlinsert); } cout << "C_DAOPerformer\tBinding values\n"; stmt.bind(1, pi.iStatus); stmt.bind(2, pi.iUseForFill); stmt.bind(3, pi.iSolosPer); stmt.bind(4, pi.iOffertoriesPer); stmt.bind(5, pi.iPreludesPer); stmt.bind(6, pi.iPostludesPer); stmt.bind(7, pi.szIdCurr); if ( !exists ) { stmt.bind(8, pi.szFirstName); stmt.bind(9, pi.szLastName); } cout << "C_DAOPerformer\tExecuting DML\n"; int rows = stmt.execDML(); if ( rows == 0 ) retVal = false; /* // ========================================== // Delete any services that are being removed // ========================================== cout << "C_DAOPerformer\tRemoving Services from performer\n"; stmt = db.compileStatement(sqldelsrvc); for( UINT i = 0, j = pi.vSrvcDel.size(); i < j; i++ ) { strcpy( tempsrvc, pi.vSrvcDel[i].c_str() ); stmt.bind(1, tempsrvc); stmt.bind(2, pi.szIdCurr); stmt.execDML(); stmt.reset(); } // ==================== // Add any new services // ==================== cout << "C_DAOPerformer\tAdding Services to performer\n"; stmt = db.compileStatement(sqlnewsrvc); for( UINT i = 0, j = pi.vSrvcAdd.size(); i < j; i++ ) { strcpy( tempsrvc, pi.vSrvcAdd[i].c_str() ); stmt.bind(1, tempsrvc); stmt.bind(2, pi.szIdCurr); stmt.execDML(); stmt.reset(); } */ // ============== // Commit changes // ============== /* cout << "C_DAOPerformer\tCommitting transaction\n"; db.execDML("commit transaction"); commitOn = false; */ cout << "C_DAOPerformer\tClosing database\n"; db.close(); } catch (CppSQLite3Exception& e) { if ( commitOn ) db.execDML("rollback"); char msg[300]; sprintf( msg, "SQLite Error: (%i) %s", e.errorCode(), e.errorMessage() ); MessageBox( GetActiveWindow(), msg, "Database Error", MB_OK | MB_ICONERROR ); retVal = false; } return retVal; } When I execute this from the Command line, this is what I get. T14. Inserting record... C_DTOPerformer::insertInfo() C_DTOPerformer::insertInfo() DAO Instance gotten C_DAOPerformer Opening Database C_DAOPerformer Compiling Insert Statement C_DAOPerformer Binding values C_DAOPerformer Executing DML C_DTOPerformer::insertInfo() DAO executed The function gets as far as the Executing DML line, then it stops. After some seconds, a message box appears with the error message in it. Any ideas from anyone would be greatly appreciated. TIA, Paul