Last active
May 7, 2022 11:58
-
-
Save musahi0128/16364da973e45f5272b60fad916b290b to your computer and use it in GitHub Desktop.
Sample codes to get query result and execute query against MySQL/MariaDB database using AutoIT and ODBC without creating ODBC data source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Global $sDBDriver = "{MariaDB ODBC 3.1 Driver}" | |
GLobal $sDBServer = "localhost" | |
Global $sDBUID = "root" | |
Global $sDBPWD = "pwd" | |
Global $sDBName = "dbname" | |
Global $sDBPort = "3306" | |
Global $sConnectionString = 'Driver=' & $sDBDriver & ';Server=' & $sDBServer & ';UID=' & $sDBUID & ';PWD=' & $sDBPWD & ';DB=' & $sDBName & ';Port=' & $sDBPort | |
Func _GetQueryResult($sQuery = "") | |
; If you don't want to make custom error handler, make sure the query always return a row | |
$DB = ObjCreate("ADODB.Connection") | |
$DB.Open($sConnectionString) | |
$Result = $DB.Execute($sQuery).GetRows() | |
$DB.Close | |
Return $Result | |
EndFunc ;==>_GetQueryResult | |
Func _QueryExecute($sQuery = "") | |
$DB = ObjCreate("ADODB.Connection") | |
$DB.Open($sConnectionString) | |
$Result = $DB.Execute($sQuery) | |
$DB.Close | |
EndFunc ;==>_QueryExecute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment