Jump to content

SQLite Problem


Recommended Posts

 

I have created this function for a database, but I can not make it work. I always have two error messages: "not an error" ... and the file created, in the script directory, does not contain anything.

Global $sDBName = "Hen.db"

Func DatabaseTable()
    Local $sConnDB
    _SQLite_Startup()
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite.dll Can't be Loaded!")
        Exit -1
    EndIf
    $sConnDB = _SQLite_Open($sDBName)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't Load Database!")
        Exit -1
    EndIf
    If Not _SQLite_Exec($sDBName, 'CREATE TABLE Animal ("Name", "Age");') = $SQLITE_OK Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
    If Not _SQLite_Exec($sDBName, 'INSERT INTO Animale VALUES ("Charlie","5");') = $SQLITE_OK Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
    _SQLite_Close($sConnDB)
    _SQLite_Shutdown()
EndFunc

 

Link to comment
Share on other sites

10 hours ago, mikell said:

You must use the handle of the previously opened database  :)

_SQLite_Exec($sConnDB, 'CREATE TABLE Animal ("Name", "Age");')

;etc

Edit
... or much simpler, use "-1"

Great... Thanks!!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...