Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connecting to oracle DB with QTP
#3
Solved: 11 Years, 4 Months, 3 Weeks ago
Hello,

Small world. Thats actually my code or a derivative of code I wrote. I recognize the naming conventions. Anyway...

It could be a few things.

-Do you have oracle client installed on the machine?
-Can you connect to the schema WPSQA manually using Toad or SQL plus?
-If both of the above or true, then open the tnsnames.ora file in your oracle installation. Search for WPSQA in that file. Make sure the service name, host, ports, user name, and password all match what is in the tnsnames file. You dont need the tnsnames for this code to work, but the connection info does need to be correct.

[quote]
thisUser = "loginid"
thisPW = "pwd"
Environment("CURRENT_SERVICE_NAME") = "WPSQA"
sql = "select * from tablename;"
ConStr = "Driver={Microsoft ODBC for Oracle}; " & _
"CONNECTSTRING=(DESCRIPTION=" & _
"(ADDRESS=(PROTOCOL=TCP)" & _
"(HOST=db-qa)(PORT=1521))" & _
"(CONNECT_DATA=(SERVICE_NAME = " & Environment("CURRENT_SERVICE_NAME") & "))); uid=" & thisUser & ";pwd=" & thisPW & ";"

Set conn1 = CreateObject("ADODB.Connection")
Set thisObjRS = CreateObject("ADODB.recordset")

conn1.ConnectionString = ConStr
conn1.Open

Set thisObjRS = conn1.Execute(sql,,adExecuteNoRecords)

varArray = thisObjRS.GetRows


But I get an error on the conn1.Open line. See error message below. Any ideas?

[Microsoft][ODBC driver for Oracle][Oracle]ORA-12154: TNS:could not resolve service name

Line (35): "conn1.Open".

Thanks & Regards,
Anita
Reply


Messages In This Thread
Connecting to oracle DB with QTP - by rajendra649 - 12-07-2011, 02:38 PM
RE: Connecting to oracle DB with QTP - by Anita2020 - 12-04-2020, 06:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  QTP 11 - Oracle Forms objects not recognised WarrenRay 0 3,186 06-23-2015, 09:35 PM
Last Post: WarrenRay
  QTP recognizing Oracle forms as Java objects shankar.srini88 0 4,671 03-25-2014, 10:26 AM
Last Post: shankar.srini88
  Connecting to database Irishman 0 4,440 07-24-2012, 11:30 PM
Last Post: Irishman
  Unable to record Oracle Forms apps and Oracle java based apps dejanbo 0 3,514 06-19-2012, 08:05 PM
Last Post: dejanbo
Exclamation QTP 11 - Object properties are lost after execution of script for Oracle Forms 11 ramapullareddy 0 2,953 12-07-2011, 04:15 PM
Last Post: ramapullareddy

Forum Jump:


Users browsing this thread: 2 Guest(s)