Hello Sqlite users. I have a problem I can't solve. I have a C++ DLL project in which I compile the Sqlite amalgamation code. The purpose is to wrap the key Sqlite functions with exported functions I can call from another C++ COM DLL. I'm using VS2003 for this because its part of a legacy product. I've been using this project for years, updating the Sqlite source code from time to time with no problems. I can call functions like sqlite3_open_v2, sqlite3_prepare, sqlite3_step, etc. with no problems. Now I'm trying to integrate the Backup API. When I call sqlite3_backup_init it throws this error: _/"library /__/ /__/routine called out of sequence"/_. I want to step into the Sqlite code to find out why but for some reason my debugger won't allow me to step into the C code from my C++ code. So I'm hoping someone can help me. Below is my C++ implementation which I modeled from the sample on this page: sqlite.org/backup.html. My calling code is from a VB6 project which simply creates/opens a memory DB and calls the below function (via my COM DLL). Any help is much appreciated.

Thanks,
BrettG


SQLITE_DLL_API int backup( /*sqlite3*/ void* pdb, const WCHAR *pFilename, BOOL toFile )
{
  int rc;
  sqlite3 *pFileDb;
  sqlite3_backup *pBackup;
  sqlite3 *pTo;
  sqlite3 *pFrom;

  CTextConverter c(CP_UTF8);
//rc = sqlite3_open_v2( c.U2M(pFilename), &pFileDb, SQLITE_OPEN_READWRITE, NULL);
  rc = sqlite3_open( c.U2M(pFilename), &pFileDb);

  if( rc==SQLITE_OK )
  {
    try
    {
        sqlite3 *pMemoryDb = (sqlite3*) pdb;
        pFrom = (toFile ? pMemoryDb : pFileDb);
        pTo   = (toFile ? pFileDb     : pMemoryDb);

// this line throws exception: "library routine called out of sequence"
*pBackup = sqlite3_backup_init(pTo, "main", pFrom, "temp");*
        if( pBackup )
        {
            sqlite3_backup_step(pBackup, -1);
            sqlite3_backup_finish(pBackup);
        }
        rc = sqlite3_errcode(pTo);
        sqlite3_close(pFileDb);
    }
    catch(...)
    {
        sqlite3_close(pFileDb);
        const char* err = sqlite3_errmsg( (sqlite3*) pdb );
        throw err;
    }
  }
  return rc;
}

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to