#include <GUIConstants.au3>
#include "mysql.au3"
Global $oMySQLError = ObjEvent("AutoIt.Error", "_MySQLError")
Opt("GUIOnEventMode", 1) ;переключаемся в режим прерывания событий OnEvent
$main_window = GUICreate ("Smile Site Edit", 800, 600) ;главное окно программы
$connect_button = GUICtrlCreateButton ("Connect DB", 730, 570) ;кнопка соединения с базой данных
GUICtrlSetOnEvent ($connect_button, "connect") ;соединение с базой данных
GUISetOnEvent ($GUI_EVENT_CLOSE, "closed")
GUISetState(@SW_SHOW)
While 1
Sleep(1000)
Wend
;функция закрытия окна
Func closed()
Exit
EndFunc
;функция соединения с базой данных
Func connect()
$sUsername = "user"
$sPassword = "pass"
$sDatabase = "db"
$sServer = "127.0.0.1"
$sDriver = "{MySQL ODBC 3.51 Driver}"
$iPort = 3306
$oConnectionObj = _MySQLConnect($sUsername, $sPassword, $sDatabase, $sServer, $sDriver, $iPort)
if not IsObj($oConnectionObj) then
Msgbox(0,"Error","$oConnectionObj is not an Object.")
else
Msgbox(0,"Error","Successfully created Object $oConnectionObj.")
endif
EndFunc
Func _MySQLError()
MsgBox(16, "MySQL Error", "err.description is : " & @TAB & $oMySQLError.Description & @CRLF & _
"err.windescription : " & @TAB & $oMySQLError.WinDescription & @CRLF & _
"err.number is : " & @TAB & Hex($oMySQLError.Number, 8) & @CRLF & _
"err.lastdllerror is : " & @TAB & $oMySQLError.LastDllerror & @CRLF & _
"err.scriptline is : " & @TAB & $oMySQLError.ScriptLine & @CRLF & _
"err.source is : " & @TAB & $oMySQLError.Source & @CRLF & _
"err.helpfile is : " & @TAB & $oMySQLError.HelpFile & @CRLF & _
"err.helpcontext is : " & @TAB & $oMySQLError.HelpContext)
Exit
SetError(1) ; to check for after this function returns
EndFunc ;==>MyErrFunc