Jump to content

Can't connect to MySQL server - (Moved)


Go to solution Solved by bogQ,

Recommended Posts

I use the UDF from Prog@ndy and have no issues  https://www.autoitscript.com/forum/index.php?showtopic=85617
 

; (put libmysql.dll and mysql.au3 into the sktipt directory)
#include ".\mysql.au3"

Func _connectDB()
    Local $DB_HOST = "xxxxx"
    Local $DB_PORT = "12345"
    Local $DB_DATABASE = "dddddd"
    Local $DB_USER = "uuuuuu"
    Local $DB_PASS = "pppppp"

    _MySQL_InitLibrary()
    If @error Then Return SetError(1, 0, 0)

    Local $connection = _MySQL_Init()
    If $connection = 0 Then Return SetError(2, 0, 0)

    Local $connected = _MySQL_Real_Connect($connection, $DB_HOST, $DB_USER, $DB_PASS, $DB_DATABASE, $DB_PORT)
    If $connected = 0 Then Return SetError(3, 0, 0)

    Return SetError(0, 0, $connection)
EndFunc

Func _disconnectDB($connection)
    _MySQL_Close($connection)
    _MySQL_EndLibrary()
EndFunc   ;==>_CloseDatabase


 

Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Link to comment
Share on other sites

I cannot find the link to the udf, the german link that is suppose to work does bring me to the udf


image.thumb.png.8df6e218e4a8725def34c77e82fe17f7.png


 and the original link also doesn't work

Edited by 20Ice18

❤️

Link to comment
Share on other sites

1 hour ago, 20Ice18 said:

this in console 

 

==> The requested action with this object has failed.:
$oConnection.Open($sConnectionString)
$oConnection^ ERROR

 

It is quite strange.
I think problem occurs in _ADO_Connection_Create()

try this modified code:

;includes...
;variables...

_ADO_ComErrorHandler_UserFunction(_ADO_COMErrorHandler)
_Example2()

Func _Example2()
    Local $oConnection = _ADO_Connection_Create()
    If @error Then ConsoleWrite("! ---> @error=" & @error & "  @extended=" & @extended & _
            " : _ADO_Connection_Create()" & @CRLF)
    ConsoleWrite('VarGetType=' & VarGetType($oConnection) & @CRLF)
    ConsoleWrite('ObjName=' & ObjName($oConnection) & @CRLF)
    
    Local $sConnectionString = "Server=" & $sServer  & "; Database=" & $sDatabase & "; Uid=" & $sUsername & "; Pwd=" & $sPassword & ";"
    _ADO_Connection_OpenConString($oConnection, $sConnectionString)
    If @error Then 
        Return SetError(@error, @extended, $ADO_RET_FAILURE)
    Else 
        MsgBox(1,  ":D",  "working")
    EndIf

    ; CleanUp
    _ADO_Connection_Close($oConnection)
    $oConnection = Null

    _ADO_REcordset_Display($aRecordset, $sTableName & '  - Recordset content')

EndFunc    ;==>_Example2

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

1 minute ago, mLipok said:

try this modified code

this was in console this time:

Starting file temprun.au3...

VarGetType=Object
ObjName=_Connection
"ADO.au3" (731) : ==> The requested action with this object has failed.:
$oConnection.Open($sConnectionString)
$oConnection^ ERROR

temprun.au3 -> Exit Code: 1 (Runtime: 2.81 sec)

 

❤️

Link to comment
Share on other sites

please try also:

    ConsoleWrite('VarGetType=' & VarGetType($oConnection) & @CRLF)
    ConsoleWrite('IsObj=' & IsObj($oConnection) & @CRLF)
    ConsoleWrite('ObjName=' & ObjName($oConnection, $OBJ_NAME) & @CRLF)
    ConsoleWrite('ObjName=' & ObjName($oConnection, $OBJ_STRING) & @CRLF)
    ConsoleWrite('ObjName=' & ObjName($oConnection, $OBJ_PROGID) & @CRLF)

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

#includes...
#variables...

_ADO_ComErrorHandler_UserFunction(_ADO_COMErrorHandler)
_Example2()

Func _Example2()
    Local $oConnection = _ADO_Connection_Create()
    If @error Then ConsoleWrite("! ---> @error=" & @error & "  @extended=" & @extended & _
            " : _ADO_Connection_Create()" & @CRLF)
    ConsoleWrite('VarGetType=' & VarGetType($oConnection) & @CRLF)
    ConsoleWrite('ObjName=' & ObjName($oConnection) & @CRLF)
    ConsoleWrite('VarGetType=' & VarGetType($oConnection) & @CRLF)
    ConsoleWrite('ObjName=' & ObjName($oConnection, $OBJ_NAME) & @CRLF)
    ConsoleWrite('ObjName=' & ObjName($oConnection, $OBJ_STRING) & @CRLF)
    ConsoleWrite('ObjName=' & ObjName($oConnection, $OBJ_PROGID) & @CRLF)
    
    Local $sConnectionString = "Server=" & $sServer  & "; Database=" & $sDatabase & "; Uid=" & $sUsername & "; Pwd=" & $sPassword & ";"
    _ADO_Connection_OpenConString($oConnection, $sConnectionString)
    If @error Then 
        Return SetError(@error, @extended, $ADO_RET_FAILURE)
    Else 
        MsgBox(1,  ":D",  "working")
    EndIf

    ; CleanUp
    _ADO_Connection_Close($oConnection)
    $oConnection = Null

    _ADO_REcordset_Display($aRecordset, $sTableName & '  - Recordset content')

EndFunc    ;==>_Example2



got this in console :
 

VarGetType=Object
ObjName=_Connection
VarGetType=Object
ObjName=_Connection
ObjName=
ObjName=ADODB.Connection.6.0
"ADO.au3" (731) : ==> The requested action with this object has failed.:
$oConnection.Open($sConnectionString)
$oConnection^ ERROR

 

❤️

Link to comment
Share on other sites

I usually work with the native SQL Server driver. Check if it's installed (the result of Get_ODBC_Drivers() function) and then try this code and let me know the result:

#include <Array.au3>

$oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

$Username = 'sa'
$Password = '<password>'

_ArrayDisplay(Get_ODBC_Drivers())

Local $oADODB = ObjCreate('ADODB.Connection')
;~ $oADODB.Open('Provider=SQLNCLI11;Server=localhost;Database=master;Integrated Security=SSPI;')    ; Windows authentication
$oADODB.Open('Provider=SQLNCLI11;Server=localhost;Database=master;', $Username, $Password)      ; SQL Server authentication
$oRowset = $oADODB.Execute('SELECT TOP 5 * FROM sys.all_columns')
$aData = $oRowset.GetRows()

_ArrayDisplay($aData)

Func _ErrFunc($oError)
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc

Func Get_ODBC_Drivers($x64 = False)
    Local $sDrivers, $sDriver, $iInstance = 1
    Do
        $sDriver = RegEnumVal('HKLM' & ($x64 ? '64' : '') & '\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers', $iInstance)
        If $sDriver Then $sDrivers &= $sDriver & Chr(1)
        $iInstance += 1
    Until Not $sDriver
    Return StringSplit(StringTrimRight($sDrivers, 1), Chr(1))
EndFunc

 

When the words fail... music speaks.

Link to comment
Share on other sites

11 minutes ago, Andreik said:
Provider=SQLNCLI11

its unknown provider:

temprun.au3 (14) : ==> COM Error intercepted !
    err.number is:      0x80020009
    err.windescription: Exception occurred.

    err.description is:     Provider cannot be found. It may not be properly installed.
    err.source is:      ADODB.Connection
    err.helpfile is:    C:\Windows\HELP\ADO270.CHM
    err.helpcontext is:     1240655
    err.lastdllerror is:    0
    err.scriptline is:  14
    err.retcode is:     0x800A0E7A

temprun.au3 (15) : ==> COM Error intercepted !
    err.number is:      0x80020009
    err.windescription: Exception occurred.

    err.description is:     Operation is not allowed when the object is closed.
    err.source is:      ADODB.Connection
    err.helpfile is:    C:\Windows\HELP\ADO270.CHM
    err.helpcontext is:     1240653
    err.lastdllerror is:    0
    err.scriptline is:  15
    err.retcode is:     0x800A0E78

temprun.au3 (16) : ==> COM Error intercepted !
    err.number is:      0x000000A9
    err.windescription: Variable must be of type 'Object'.
    err.description is:     
    err.source is:      
    err.helpfile is:    
    err.helpcontext is:     
    err.lastdllerror is:    0
    err.scriptline is:  16
    err.retcode is:     0x00000000


 

Edited by 20Ice18

❤️

Link to comment
Share on other sites

  • Solution

https://dev.mysql.com/downloads/file/?id=517870     32-bit driver for 32bit autoit

or direct link https://dev.mysql.com/get/Downloads/Connector-ODBC/8.0/mysql-connector-odbc-8.0.33-win32.msi

 

#include "ADO.au3"
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>

_Example_ListProperties()

Func _Example_ListProperties()
    Local $sConnectionString = _ADO_ConnectionString_MySQL('root', '', 'test', 'MySQL ODBC 8.0 ANSI Driver', 'localhost', '3306')
    Local $oConnection = _ADO_Connection_Create()
    _ADO_Connection_OpenConString($oConnection, $sConnectionString)
    If @error Then MsgBox(0,@error,@extended)
    Local $aRecordset = _ADO_Execute($oConnection, "SELECT * FROM testtable", True)
    If @error Then MsgBox(0,@error,@extended)
    _ADO_Connection_Close($oConnection)
    $oConnection = Null
    _ADO_Recordset_Display($aRecordset, 'Recordset content')
    If @error Then MsgBox(0,@error,@extended)
EndFunc   ;==>_Example_2_RecordsetDisplay

image.thumb.png.04d9ee141b04dc3cbb4df71bc3c1dd95.png

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

next snippet to test:

#include <Array.au3>
#include "ADO.au3"

#variables...

$oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
_ArrayDisplay(Get_ODBC_Drivers())

Local $sConnectionString = "Server=" & $sServer  & "; Database=" & $sDatabase & "; Uid=" & $sUsername & "; Pwd=" & $sPassword & ";"
Local $oConnection = ObjCreate('ADODB.Connection')
$oConnection.Open($sConnectionString)      ; SQL Server authentication
Local $s_QUERY = 
$oRowset = $oConnection.Execute($s_QUERY)
$aData = $oRowset.GetRows()

_ArrayDisplay($aData, 'TEST 1')

$aData = _ADO_Execute($oConnection, '$s_QUERY', True,True)
_ArrayDisplay($aData, 'TEST 2')

Func _ErrFunc($oError)
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc

Func Get_ODBC_Drivers($x64 = False)
    Local $sDrivers, $sDriver, $iInstance = 1
    Do
        $sDriver = RegEnumVal('HKLM' & ($x64 ? '64' : '') & '\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers', $iInstance)
        If $sDriver Then $sDrivers &= $sDriver & Chr(1)
        $iInstance += 1
    Until Not $sDriver
    Return StringSplit(StringTrimRight($sDrivers, 1), Chr(1))
EndFunc

EDIT:
here I use modfied @Andreik example.

As you can see we are using the same $oConnection but in different ways we get data.

Local $sConnectionString = "Server=" & $sServer  & "; Database=" & $sDatabase & "; Uid=" & $sUsername & "; Pwd=" & $sPassword & ";"
Local $oConnection = ObjCreate('ADODB.Connection')
$oConnection.Open($sConnectionString)      ; SQL Server authentication
Local $s_QUERY = 
$oRowset = $oConnection.Execute($s_QUERY)
$aData = $oRowset.GetRows()

_ArrayDisplay($aData, 'TEST 1')

$aData = _ADO_Execute($oConnection, '$s_QUERY', True,True)
_ArrayDisplay($aData, 'TEST 2')

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

4 minutes ago, mLipok said:

next snippet to test:

output:
 

temprun.au3 (13) : ==> COM Error intercepted !
    err.number is:      0x80020009
    err.windescription: Exception occurred.

    err.description is:     [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
    err.source is:      Microsoft OLE DB Provider for ODBC Drivers
    err.helpfile is:    
    err.helpcontext is:     0
    err.lastdllerror is:    0
    err.scriptline is:  13
    err.retcode is:     0x80004005

temprun.au3 (15) : ==> COM Error intercepted !
    err.number is:      0x80020009
    err.windescription: Exception occurred.

    err.description is:     Operation is not allowed when the object is closed.
    err.source is:      ADODB.Connection
    err.helpfile is:    C:\Windows\HELP\ADO270.CHM
    err.helpcontext is:     1240653
    err.lastdllerror is:    0
    err.scriptline is:  15
    err.retcode is:     0x800A0E78

temprun.au3 (16) : ==> COM Error intercepted !
    err.number is:      0x000000A9
    err.windescription: Variable must be of type 'Object'.
    err.description is:     
    err.source is:      
    err.helpfile is:    
    err.helpcontext is:     
    err.lastdllerror is:    0
    err.scriptline is:  16
    err.retcode is:     0x00000000

temprun.au3 (886) : ==> COM Error intercepted !
    err.number is:      0x80020009
    err.windescription: Exception occurred.

    err.description is:     Operation is not allowed when the object is closed.
    err.source is:      ADODB.Connection
    err.helpfile is:    C:\Windows\HELP\ADO270.CHM
    err.helpcontext is:     1240653
    err.lastdllerror is:    0
    err.scriptline is:  886
    err.retcode is:     0x800A0E78

 

❤️

Link to comment
Share on other sites

2 minutes ago, 20Ice18 said:
	err.description is: 	[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
	err.source is: 		Microsoft OLE DB Provider for ODBC Drivers
	err.helpfile is: 	

so we have to use:

Driver={MySQL ODBC 5.2 ANSI Driver};Server=myServerAddress;Port=3306;Database=myDataBase;User=myUsername;Password=myPassword;Option=3;

instead:

https://www.connectionstrings.com/mysql/

Specifying TCP port

Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

17 minutes ago, bogQ said:

https://dev.mysql.com/downloads/file/?id=517870     32-bit driver for 32bit autoit

 

so we had to check this snippet:

#include <Array.au3>
#include "ADO.au3"

#variables...

Local $s_QUERY = '' ; your query

$oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
_ArrayDisplay(Get_ODBC_Drivers())

Local $sDriver = "MySQL ODBC 8.0 ANSI Driver" ;https://dev.mysql.com/downloads/file/?id=517870     32-bit driver for 32bit autoit
Local $sConnectionString = "Driver=" & $sDriver & ";" &"Server=" & $sServer  & "; Database=" & $sDatabase & "; Uid=" & $sUsername & "; Pwd=" & $sPassword & ";"
Local $oConnection = ObjCreate('ADODB.Connection')
$oConnection.Open($sConnectionString)      ; SQL Server authentication
$oRowset = $oConnection.Execute($s_QUERY)
$aData = $oRowset.GetRows()

_ArrayDisplay($aData, 'TEST 1')

$aData = _ADO_Execute($oConnection, '$s_QUERY', True,True)
_ArrayDisplay($aData, 'TEST 2')

Func _ErrFunc($oError)
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc

Func Get_ODBC_Drivers($x64 = False)
    Local $sDrivers, $sDriver, $iInstance = 1
    Do
        $sDriver = RegEnumVal('HKLM' & ($x64 ? '64' : '') & '\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers', $iInstance)
        If $sDriver Then $sDrivers &= $sDriver & Chr(1)
        $iInstance += 1
    Until Not $sDriver
    Return StringSplit(StringTrimRight($sDrivers, 1), Chr(1))
EndFunc

 

REMARK: without testing ... I have no access to MySQL even not saving this file and not testing with TIDY/AU3check

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

38 minutes ago, 20Ice18 said:

its unknown provider:

temprun.au3 (14) : ==> COM Error intercepted !
    err.number is:      0x80020009
    err.windescription: Exception occurred.

    err.description is:     Provider cannot be found. It may not be properly installed.
    err.source is:      ADODB.Connection
    err.helpfile is:    C:\Windows\HELP\ADO270.CHM
    err.helpcontext is:     1240655
    err.lastdllerror is:    0
    err.scriptline is:  14
    err.retcode is:     0x800A0E7A

temprun.au3 (15) : ==> COM Error intercepted !
    err.number is:      0x80020009
    err.windescription: Exception occurred.

    err.description is:     Operation is not allowed when the object is closed.
    err.source is:      ADODB.Connection
    err.helpfile is:    C:\Windows\HELP\ADO270.CHM
    err.helpcontext is:     1240653
    err.lastdllerror is:    0
    err.scriptline is:  15
    err.retcode is:     0x800A0E78

temprun.au3 (16) : ==> COM Error intercepted !
    err.number is:      0x000000A9
    err.windescription: Variable must be of type 'Object'.
    err.description is:     
    err.source is:      
    err.helpfile is:    
    err.helpcontext is:     
    err.lastdllerror is:    0
    err.scriptline is:  16
    err.retcode is:     0x00000000


 

Install it :rolleyes: or let us know what drivers you already have.

When the words fail... music speaks.

Link to comment
Share on other sites

@mLipok about this line dono if itl work with no {}

so from

$sDriver = "MySQL ODBC 8.0 ANSI Driver"

to

$sDriver = "{MySQL ODBC 8.0 ANSI Driver}"

coz of clean in string usage?

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

4 minutes ago, mLipok said:

so we had to check this snippet:

#include <Array.au3>
#include "ADO.au3"

#variables...

$oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
_ArrayDisplay(Get_ODBC_Drivers())

Local $sDriver = "MySQL ODBC 8.0 ANSI Driver" ;https://dev.mysql.com/downloads/file/?id=517870     32-bit driver for 32bit autoit
Local $sConnectionString = "Driver=" & $sDriver & ";" &"Server=" & $sServer  & "; Database=" & $sDatabase & "; Uid=" & $sUsername & "; Pwd=" & $sPassword & ";"
Local $oConnection = ObjCreate('ADODB.Connection')
$oConnection.Open($sConnectionString)      ; SQL Server authentication
Local $s_QUERY = 
$oRowset = $oConnection.Execute($s_QUERY)
$aData = $oRowset.GetRows()

_ArrayDisplay($aData, 'TEST 1')

$aData = _ADO_Execute($oConnection, '$s_QUERY', True,True)
_ArrayDisplay($aData, 'TEST 2')

Func _ErrFunc($oError)
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc

Func Get_ODBC_Drivers($x64 = False)
    Local $sDrivers, $sDriver, $iInstance = 1
    Do
        $sDriver = RegEnumVal('HKLM' & ($x64 ? '64' : '') & '\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers', $iInstance)
        If $sDriver Then $sDrivers &= $sDriver & Chr(1)
        $iInstance += 1
    Until Not $sDriver
    Return StringSplit(StringTrimRight($sDrivers, 1), Chr(1))
EndFunc

 

I still don't get this confusion. It's SQL Server or MySQL? They are not the same.

When the words fail... music speaks.

Link to comment
Share on other sites

1 minute ago, Andreik said:

Install it :rolleyes: or let us know what drivers you already have.

I have 32 bit ODBC Driver 17 for SQL Server and SQL Server and 64 bit MySQL ODBC 8.0 ANSI Driver, MySQL ODBC 8.0 Unicode Driver, ODBC Driver 17 for SQL Server and SQL Server

I'm afraid that I  was using MySQL ODBC 8.0 ANSI Driver 64 bit on 32 bit Autoit. 

❤️

Link to comment
Share on other sites

For MySQL I use MySQL ODBC 8.0 Unicode Driver and connection string:

Quote

Driver={MySQL ODBC 8.0 Unicode Driver};Server=<server>;Database=<database>;User=<username>;Password=<password>;Port=3306;Option=10;

But again, you must have the driver that you use installed. Use this code to list the installed drivers and show us the result.

$aDriver = Get_ODBC_Drivers()

For $Index = 1 To $aDriver[0]
    ConsoleWrite($aDriver[$Index] & @CRLF)
Next

Func Get_ODBC_Drivers($x64 = False)
    Local $sDrivers, $sDriver, $iInstance = 1
    Do
        $sDriver = RegEnumVal('HKLM' & ($x64 ? '64' : '') & '\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers', $iInstance)
        If $sDriver Then $sDrivers &= $sDriver & Chr(1)
        $iInstance += 1
    Until Not $sDriver
    Return StringSplit(StringTrimRight($sDrivers, 1), Chr(1))
EndFunc

 

Edited by Andreik

When the words fail... music speaks.

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