SQLite library
Posted: Fri Jan 01, 2010 3:32 pm
I`m trying to write a library to access the sqlite3.dll.
So far I managed to get the version number:
CONST SQLITE3_DLL = "sqlite3.dll"
DECLARE dll_sqlite3_libversion_number AS "sqlite3_libversion_number" OF SQLITE3_DLL
DIM RESULT AS INTEGER
END DECLARE
FUNCTION sqlite3_libversion_number() AS INTEGER
dll_sqlite3_libversion_number
RESULT=dll_sqlite3_libversion_number.RESULT
END FUNCTION
` Shows the version of the SQLITE DBMS as message.
SUB ShowDbVersion()
ShowMessage "SQLite Version: "+STR$(sqlite3_libversion_number())
END SUB
But trying to open an existing database fails and crashes the whole app:
`int sqlite3_open
DECLARE dll_sqlite3_open AS "sqlite3_open" OF SQLITE3_DLL
`const char *filename, /* Database filename (UTF-8) */
DIM filename AS STRING
`sqlite3 **ppDb /* OUT: SQLite db handle */
DIM ppDb AS LONG BYADDRESS
` Result
DIM RESULT AS INTEGER
END DECLARE
FUNCTION sqlite3_open(filename AS STRING, ppDb AS LONG BYADDRESS) AS INTEGER
dll_sqlite3_open.filename=filename
dll_sqlite3_open.ppDb=ppDb
dll_sqlite3_open
RESULT=dll_sqlite3_open.RESULT
END FUNCTION
DIM ppDB AS LONG ` global db handler
` Should open a SQLITE database but crashes the app.
SUB DbOpen()
ShowMessage "SQLite Open: "+STR$(sqlite3_open("c:midgard_import.db3", ppDB))
END SUB
I doubt that I set the parameter types for the dll call correctly.
So how should I declare them?
So far I managed to get the version number:
CONST SQLITE3_DLL = "sqlite3.dll"
DECLARE dll_sqlite3_libversion_number AS "sqlite3_libversion_number" OF SQLITE3_DLL
DIM RESULT AS INTEGER
END DECLARE
FUNCTION sqlite3_libversion_number() AS INTEGER
dll_sqlite3_libversion_number
RESULT=dll_sqlite3_libversion_number.RESULT
END FUNCTION
` Shows the version of the SQLITE DBMS as message.
SUB ShowDbVersion()
ShowMessage "SQLite Version: "+STR$(sqlite3_libversion_number())
END SUB
But trying to open an existing database fails and crashes the whole app:
`int sqlite3_open
DECLARE dll_sqlite3_open AS "sqlite3_open" OF SQLITE3_DLL
`const char *filename, /* Database filename (UTF-8) */
DIM filename AS STRING
`sqlite3 **ppDb /* OUT: SQLite db handle */
DIM ppDb AS LONG BYADDRESS
` Result
DIM RESULT AS INTEGER
END DECLARE
FUNCTION sqlite3_open(filename AS STRING, ppDb AS LONG BYADDRESS) AS INTEGER
dll_sqlite3_open.filename=filename
dll_sqlite3_open.ppDb=ppDb
dll_sqlite3_open
RESULT=dll_sqlite3_open.RESULT
END FUNCTION
DIM ppDB AS LONG ` global db handler
` Should open a SQLITE database but crashes the app.
SUB DbOpen()
ShowMessage "SQLite Open: "+STR$(sqlite3_open("c:midgard_import.db3", ppDB))
END SUB
I doubt that I set the parameter types for the dll call correctly.
So how should I declare them?