I want to be able to either load or save db between memory and file. I have attempted to use the handle to sqlite3 api from the Qsqldatabase object.

I follow the example code to obtain the driver. The function is passed Qsqldatabase pointer for the two databases.

Showing snippet for one db to obtain handle:

v = db1->driver()->handle();
if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*")==0)
// v.data() returns a pointer to the handle
pInMemory = *static_cast<sqlite3 **>(v.data());

After checking that both handles are not null, I decide which is the src and dest db and load the to/from sqlite3 pointers ( same as the backup example on Sqlite website)

sqlite3_backup_init(pTo, "main", pFrom, "main");

I receive the following error:

First-chance exception at 0x00000000 in xxx.exe: 0xC0000005: Access violation reading location 0x00000000.

Note: I am using the qt sqlite library. To get to the sqlite api I have also included the sqlite3 library in the build (Found couple of online references to doing this).

Can anyone shed light on this error when using the driver ahndle to sqlite api?

Thanks