carabusu Posted May 11, 2007 Share Posted May 11, 2007 i have a problem running my script on other PC; on my PC it works fine the code is:; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $ado = ObjCreate( "ADODB.Connection" ) with $ado .ConnectionString =("Provider='OraOLEDB.Oracle';Data Source='maindb';User Id='x';Password='x';") .open EndWith Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Test","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 the error is: ORA-12154: TNS: could not resolve the connect identifier specified the tnsname.ora file is ok because with the SQL plus i can connect to that database with that username and password what could it be wrong? pls help Link to comment Share on other sites More sharing options...
lordofthestrings Posted May 11, 2007 Share Posted May 11, 2007 what does TNSPING say? tnsping databasename should give you a resolving of the database to servername. then it should connect to the oracle port to verify if a connection is phisically possible. if this is not possible check dns resolving and possibly add hostname and IP address of the server to hostfile under windows\sys32\drivers\etc\host let me know how it goes... Dimitri Link to comment Share on other sites More sharing options...
carabusu Posted May 11, 2007 Author Share Posted May 11, 2007 tnsping maindb TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 11-MAY-2 007 09:35:38 Copyright © 1997, 2005, Oracle. All rights reserved. Used parameter files: D:\oracle\product\10.2.0\db_2\network\admin\sqlnet.ora Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = xx)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = maindb))) OK (10 msec) Link to comment Share on other sites More sharing options...
lordofthestrings Posted May 11, 2007 Share Posted May 11, 2007 (edited) I see no quotes in the connection string built by the "connection string editor" (free download at the code project)Provider=MSDAORA.1; (this should be your oracle driver)User ID=x;Password=x;Data Source=SERVERHOSTNAME;Persist Security Info=TRUEso I would use this as connection string:'Provider=MSDAORA.1;User ID=x;Password=x;Data Source=mainDB;Persist Security Info=TRUE'also plz check:http://ora-12154.ora-code.com/ Edited May 11, 2007 by lordofthestrings Link to comment Share on other sites More sharing options...
carabusu Posted May 11, 2007 Author Share Posted May 11, 2007 perfect it's working many thanks to u man Link to comment Share on other sites More sharing options...
lordofthestrings Posted May 11, 2007 Share Posted May 11, 2007 your verry welcome buddy.. Link to comment Share on other sites More sharing options...
carabusu Posted May 11, 2007 Author Share Posted May 11, 2007 it can be another drive than this? because i can connect to some database and i can't to others tnsping it's ok (TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 11-MAY-2 007 13:11:17 Copyright © 1997, 2005, Oracle. All rights reserved. Used parameter files: D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 10.27.0.50)(PORT = 1521))) (CONNECT_DATA = (SID = amex) (SERVER = DEDICA TED))) OK (20 msec) and i can't connect to this database (same errors with tnsname) Link to comment Share on other sites More sharing options...
carabusu Posted May 11, 2007 Author Share Posted May 11, 2007 (edited) i've figure out what the problem is my code is: expandcollapse popup$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $sql1 = ObjCreate( "ADODB.Connection" ) ; Create a COM ADODB Object with the Beta version With $sql1 .ConnectionString =('Provider=MSDAORA.1;User ID=xxx_av;Password=xxx;Data Source=maindb;Persist Security Info=TRUE') .Open EndWith if $oMyError.description=="" then FileWrite($file,"STEP 4 ---PASSED--- Connection to xxx_AV established" & @CRLF) Else FileWrite($file,"STEP 4 ---FAILED--- Connection to xxx_AV couldn't be established" & @CRLF) EndIf $sql1.Close ;;;;;;;;;;;;;;;;;; END FOR xxx_AV;;;;;;;;;;; ;;;;;;;;;;;;;;;;; FOR xxx_DW;;;;;;;;;;;;;;;;; $sql2 = ObjCreate( "ADODB.Connection" ) ; Create a COM ADODB Object with the Beta version With $sql2 .ConnectionString =('Provider=MSDAORA.1;User ID=xxx_dw;Password=xxx;Data Source=maindb;Persist Security Info=TRUE') .Open EndWith if $oMyError.description=="" then FileWrite($file," ---PASSED--- Connection to xxx_DW established" & @CRLF) Else FileWrite($file," ---FAILED--- Connection to xxx_DW couldn't be established" & @CRLF) EndIf $sql2.Close ;;;;;;;;;;;;;;;;;END FOR xxx_DW;;;;;;;;;;;;;;;;;;;; Func MyErrFunc() $HexNumber=hex($oMyError.number,2) return $omyerror.description EndFunc the problem is that if first user doesn't exist the $omyerror is diferent than "" and in my file for the second user ,which exist , it tells me FAILED what can i do with $oMyError.description to give it value="" after the first user verification if i put $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") before sql2 too it gives me error : operation not allowed when the object is closed and i can't put $oMyError.description="" in the first line of the MyErrFunc function any ideea to make MyErrFunc work corectly with sql1 and sql2 or i can use something else than MyErrFunc to tell me if the database connection is established and put than into my file? Edited May 11, 2007 by carabusu Link to comment Share on other sites More sharing options...
lordofthestrings Posted May 11, 2007 Share Posted May 11, 2007 how about simply using tnsping to prove that your connection to the database is there? that's why the tool was designed.. to test connectivity issues.. it can be a host name resolving problem, or it can be an other TCP related problem like connection can not be established.. if you see the last <OK>, it means that it connected to the database without errors.. I would launch that from my autoIT script using the run or runwait function.. hope this helps.. to actually test if you can log in the database, I would use OSQL.EXE or ISQL.EXE .. SQLPlus /nolog is another command that gives some feedback can be used for troubleshooting.. Link to comment Share on other sites More sharing options...
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