Jump to content

EzMysql UDF crashing?


DrSeuss
 Share

Recommended Posts

I'm using EzMysql to read from and write to a remotely hosted mysql database.

It opens the database fine, and reads and write fine, but if there is ever a delay of greater than 16 seconds between two Ezmysql read or write commands, it starts throwing errors and the commands no longer work. It's like the connection times out.

The trouble is, I can't just reopen the connection. If I issue an _EzMySql_Close() command followed by an _EzMySql_Open(), it crashes.

(My prefered habit would be to close the connection after every query, but I can't get that to work either.)

And regardless of whether it has errored on the 16 second timeout, every time I go to unload the sql dll from memory with the _EzMySql_Shutdown() command, the function returns an error indicating it hasn't unloaded properly. This may or may not be related.

Basically, if my programs sits for 16 seconds or more waiting for user input, it needs to be restarted to work again.

This happens on all of my ten or so PCs, both Windows XP 32 bit and Windows 7 64-bit. I've never seen anyone report this on the forum, so I figure I'm doing something wrong. Any clues?

I'd provide full sample code except you need a live mysql database. But here are the functions in question, simplified to protect my passwords etc:

_StartSQL()
_OpenDB()
_WriteDB()
_CloseDB()
_StopSQL()

Func _StartSQL()
    If _EzMySql_Startup() Then
        _DisplayMessage("MySQL started successfully")
    Else
        _DisplayMessage("Error Starting MySql "& @error &  _EzMySql_ErrMsg())
    EndIf
EndFunc
Func _OpenDB()
    Local $Password = "blah blah"
    Local $Server = "blah blah"
    Local $User = "blah"
    Local $Port = "3306"
    Local $Database = "blah"
    If _EzMySql_Open($Server,$User,$Password, "", $Port) Then
        _DisplayMessage("Database connection made successfully")
    Else
        _DisplayMessage("Error connecting to database "& @error & _EzMySql_ErrMsg())
        Sleep(10000)
    EndIf
    If  _EzMySql_SelectDB($Database) Then
        _DisplayMessage("Database opened successfully")
    Else
        _DisplayMessage("Error opening database "& @error & _EzMySql_ErrMsg())
    EndIf
EndFunc
Func _WriteDB($Table, $Product, $Attribute, $Value)
    Local $Query = "SELECT blah blah"
    _EzMySql_Query($Query)
    Local $RowsChanged = _EzMySql_FetchData()
    If @error Then
        _DisplayMessage("Writing to DB threw an error!")
   THIS IS WHERE I GET AN ERROR IF THERE IS EVER A 16 SECOND OR LONGER DELAY BETWEEN DATABASE ACTIVITIES
        Return
    EndIf  
EndFunc
Func _CloseDB()
    _EzMySql_Close()
    _DisplayMessage("Database closed")
EndFunc
Func _StopSQL()
    If _EzMySql_Shutdown() Then
        _DisplayMessage("MySQL stopped successfully")
        sleep(100)
    Else
        _DisplayMessage("Error Stopping MySql "& @error &  _EzMySql_ErrMsg())
THIS ALWAYS ALWAYS ALWAYS DISPLAYS THIS ERROR MESSAGE
    EndIf
EndFunc

Any help appreciated. I can't see what I am doing wrong. I've searched the forum for "ezmysql timeout" and the like but to no avail.

John

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...