开发者

SQlite3 Database Using Exception

I am using a wrapper SQLITE3 to access sqlite3 data base, every thing is fine and i closed all the data bases I already have opened, but when my application is finished the execution and while execute (return 0;) in the main program the following exception 开发者_运维百科rise:

Unhandled exception at 0x75d9b727 in SQLCONVERTOR.exe: Microsoft C++ exception: CppSQLite3 Exception at memory location 0x0026f8d0..

at the following code:

void __cdecl exit (
        int code
        )
{
        doexit(code, 0, 0); /* full term, kill process */
}

I am a c++ programmer and i spent around a month in solving this issue but nothing at all.

if any one have any idea what i have to do? how i have to think? i appreciate his/here help.


sqlite3 is in C therefore does not throw exceptions.

What you are actually getting is an access violation, which Microsoft is turning into an exception.

The problem is we cannot see any of your code.


The problem was That I mix using some APIs from the C Interface and some functions from the CPPSqlite3 Wrapper, Basically, using sqlite3_close API is different from close function in the wrapper, the wrapper set the DB pointer to null, while the sqlite3_close dose not do and hence you have to do that manually.

In other Words: The C parameter to sqlite3_close(C) must be either a NULL pointer or an sqlite3 object pointer obtained from sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2(), and not previously closed. Calling sqlite3_close() with a NULL pointer argument is a harmless no-op.

my mistake Was:

while( (pStmt = sqlite3_next_stmt(NewDB.mpDB, 0))!=0 )
{
    sqlite3_finalize(pStmt);
}
sqlite3_close (NewDB.mpDB);

while it should be:

while( (pStmt = sqlite3_next_stmt(NewDB.mpDB, 0))!=0 )
{
    sqlite3_finalize(pStmt);
}
NewDB.close();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜