Press Posted June 8, 2020 Posted June 8, 2020 (edited) Hi All, I am new to AutoIT and i couldn't establish a connection to a oracle DB through AutoIT script Below is my code i tried few connection strings to connect but none of them worked and i was getting a com error each time expandcollapse popup#include <StaticConstants.au3> #include <WindowsConstants.au3> #include <SQLite.au3> #include <SQLite.dll.au3> Local $ServerAddress = "xxxxxx.xxxx.cloudapp.azure.com" Local $ServerUserName = "xxxxxxx" Local $ServerPassword = "xxxxxxx" Local $Database = "xxxx" Local $username = 'PHTestUser' Local $Driver = "{Microsoft ODBC for Oracle}" Dim $oMyError ; Initializes COM handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ;$conn1 = "Driver={Microsoft ODBC for Oracle};Server=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxxxx.xxxx.cloudapp.azure.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=xxx)));Uid=xxx;Pwd=xxxx; ;$conn2= "Provider='OraOLEDB.Oracle';SERVER=xxxx.xxx.cloudapp.azure.com;DATABASE=india;uid=xxxx;pwd=xxxx;" $conn3="Provider=OraOLEDB.Oracle;Data Source=xxxx.xxxx.cloudapp.azure.com:1521;Initial Catalog=$Database;User Id=xxxx;Password=xxxxx;" $ObjConn = ObjCreate("ADODB.Connection") MsgBox(0,"",$conn) $Objconn.open ($conn) If @error Then ConsoleWrite(@error & @CRLF) EndIf $sQuery = "select * from users where username=" & $username ;$result = $ObjConn.Execute($sQuery) ;MsgBox(0, "", $result.username( " = username" ).Value) ;ConsoleWrite($result.username & " username present") ;$ObjConn.Close ; ==> Close the database ; This COM error Handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) ConsoleWrite("We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc Output: 1. conn1 = We intercepted a COM Error ! err.description is: Catastrophic failure err.windescription: Exception occurred. err.number is: 80020009 err.lastdllerror is: 0 err.scriptline is: 66 err.source is: Provider 2. Conn2 = We intercepted a COM Error ! err.description is: ORA-12560: TNS:protocol adapter error err.windescription: Exception occurred. err.number is: 80020009 err.lastdllerror is: 0 err.scriptline is: 66 err.source is: OraOLEDB 3. Conn3 = We intercepted a COM Error ! err.description is: ORA-12170: TNS:Connect timeout occurred err.windescription: Exception occurred. err.number is: 80020009 err.lastdllerror is: 0 err.scriptline is: 66 err.source is: OraOLEDB it would be much helpful if anyone can suggest what might be the issue Edited June 8, 2020 by Jos added codebox <>
Developers Jos Posted June 8, 2020 Developers Posted June 8, 2020 Moved to the appropriate forum. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
bogQ Posted June 9, 2020 Posted June 9, 2020 (edited) On first glance "Initial Catalog=$Database;User" should be like "Initial Catalog=" & $Database & ";User" btw take a look @ because as far as i see you tested code from But did not look @ answer Edited June 9, 2020 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now