Jump to content

EzMySql_Dll.au3 Problems with creating .dll


Go to solution Solved by Andreik,

Recommended Posts

I encountered issues while attempting to use the EzMySql UDF made by @Yoriz

 Specifically, I faced difficulties in creating the .dll file using http://www.mediafire.com/?ztmzzlozzlw, which turned out to be empty.

While running the AutoIt script, I encountered some undeclared global and local variables, which I tried to rectify.

However, despite my efforts, I am still encountering the following error when running the script:

image.png.bf5930e7735466b105bdcaffbfcbf3f8.png


After this MsgBox it creates empty  .dll file in script directory.

If anyone knows what could be causing this please let me know. 

Edited by 20Ice18

❤️

Link to comment
Share on other sites

I'm getting error that variable is not declared 

image.png.5c0350fbd8a09c4f1d53551cdb430cc2.png

even tho its declared right here 

image.png.866a211b80f6fd2bc4f9a3aea53e26e0.png

 

EzMySql.au3" (98) : ==> Variable used without being declared.:
$hEzMySql_Dll = DllOpen($hEzMySql_DllLoc)
^ ERROR

 

Edited by 20Ice18

❤️

Link to comment
Share on other sites

I think I fixed that by just declaring them again 

 

but now im getting error while executing a query 

 

Func data_computers_insert()
    Local $serialNumber
    Local $computerName
    Local $submissionDate
    Local $sqlQuery

    ; Start the MySQL connection
    _EzMySql_Startup()

    ; Open the connection to the database
    _EzMySql_Open($str_db_host, $str_db_user, $str_db_password, $str_database, "3306")
    If @error Then
        MsgBox(16, "Error", "Failed to open the MySQL connection.")
        Return
    EndIf

    ; Set the values for the computer
    $serialNumber = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "SystemProductName")
    If @error Then
        MsgBox(16, "Error", "Failed to read the serial number from the registry.")
        _EzMySql_Close()
        _EzMySql_ShutDown()
        Return
    EndIf

    $computerName = @ComputerName
    $submissionDate = @YEAR & "-" & @MON & "-" & @MDAY

    ; Build the SQL query
    $sqlQuery = "INSERT INTO Computer (serial_number, computer_name, submission_date) VALUES ('" & $serialNumber & "', '" & $computerName & "', '" & $submissionDate & "')"

    ; Execute the query
    _EzMySql_Exec($sqlQuery)
    If @error Then
        MsgBox(16, "Error", "Failed to execute the SQL query.")
        _EzMySql_Close()
        _EzMySql_ShutDown()
        Return
    EndIf

    _EzMySql_Close()
    _EzMySql_ShutDown()
EndFunc


this one :

MsgBox(16, "Error", "Failed to execute the SQL query.")

 

❤️

Link to comment
Share on other sites

yea the error code is 3 

image.png.aa3cfa8ec90a7ce0a609ef85393e90ba.png

 

Func _EzMySql_Exec($querystring)
    Local $execError, $iNextResult
    If $sEzMySql_Result Then _EzMySql_QueryFinalize()
    If Not $hEzMySql_Ptr Then Return SetError(1, 0, 0)
    If Not $querystring Then Return SetError(5, 0, 0)
    $querystringlength = StringLen($querystring)
    _EzMySql_MultiLine()
    Local $query = DllCall($hEzMySql_Dll, "int", "mysql_real_query", "ptr", $hEzMySql_Ptr, "str", $querystring, "ulong", $querystringlength)
    If @error Then $execError = 2
    If _EzMySql_ErrMsg() Then Return SetError(3, 0, 0)
    Do
        Local $result = DllCall($hEzMySql_Dll, "ptr", "mysql_store_result", "ptr", $hEzMySql_Ptr)
        $sEzMySql_Result = $result[0]
        _EzMySql_QueryFinalize()
        $iNextResult = DllCall($hEzMySql_Dll, "int", "mysql_next_result", "ptr", $hEzMySql_Ptr)
    Until $iNextResult[0] <> 0
    _EzMySql_MultiLine(False)
    If $execError Then Return SetError($execError, 0, 0)
    Return 1
EndFunc   ;==>_EzMySql_Exec

which was set by _EzMySql_ErrMsg() according to this I suppose 

and that function is here  but i don't see any 3s 

 

; #FUNCTION# ====================================================================================================================
; Name...........: _EzMySql_ErrMsg
; Description ...: returns a null-terminated string containing the error message for the most recen function that failed.
; Syntax.........: _EzMySql_ErrMsg()
; Parameters ....: None
; Return values .: On Success - A null-terminated character string that describes the error. An empty string if no error occurred
; Return values .: On Failure - returns 0 and @error value
;                    1 - A MySQL struct does not exist
;                    2 - Dll Call failed
; Author ........: Yoriz
; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy
; ===============================================================================================================================
Func _EzMySql_ErrMsg()
    If Not $hEzMySql_Ptr Then Return SetError(1, 0, 0)
    Local $errors = DllCall($hEzMySql_Dll, "str", "mysql_error", "ptr", $hEzMySql_Ptr)
    If @error Then Return SetError(2, 0, 0)
    If $errors[0] Then Return $errors[0]
    Return 0
EndFunc   ;==>_EzMySql_ErrMsg



 

❤️

Link to comment
Share on other sites

  • Solution

First of all display in console your query and manually execute it in phpmyadmin or whatever are you using for mysql to be sure your query doesn't have any funny characters that should be escaped. Then check if DllCall() fails in _EzMySql_ErrMsg() or the function just returns fine and what is the returned value.

When the words fail... music speaks.

Link to comment
Share on other sites

 

20 minutes ago, Andreik said:

First of all display in console your query and manually execute it in phpmyadmin or whatever are you using for mysql to be sure your query doesn't have any funny characters that should be escaped. Then check if DllCall() fails in _EzMySql_ErrMsg() or the function just returns fine and what is the returned value.

My data was too long for the column, I had to Modify Column in Table first.

Thank youu ❤️ @Andreik

I should probably take a break from coding today XD 

Edited by 20Ice18

❤️

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...