Getting DB Connection Error on QTP

122 views
Skip to first unread message

Vishnu V.Potti

unread,
Feb 23, 2010, 10:20:08 AM2/23/10
to QTP Automation Experts Group
Hi All,

I tried to connect my DB via QTP. I used the below Script in QTP for
connecting and querying DB. Iam gettign this below error in dialog
box
"[Oracle][ODBC][Ora]ORA-12560: TNS:protocol adapter error
Line (22): "conn1.Open".

Note: First I used one host in connection string. Still I got the same
error. I also set up "MYDB" datasource in "System DSN" tab on
Control Panel -> Administrative Tools ->Data Sources (ODBC) for
"Oracle in OraClient10g_home1" driver. I tested the connection after
setting uphere and the connection was successful. I am able to connect
to MYDB through TOAD application.

Please advice me how to correct the script.

************Starting of Script******************

thisUser = username
thisPW = password
Environment("CURRENT_SERVICE_NAME") = "MYDB_APP.company.net"
sql = "select * from my_table';"
ConStr = "Driver={Oracle in OraClient10g_home1}; " & _
"CONNECTSTRING=(DESCRIPTION=" & _
"(ADDRESS = (PROTOCOL = TCP)" & _
"(host = abcn01p.company.net || host = def03v2.company.net)
(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(query,,adExecuteNoRecords)
varArray = thisObjRS.GetRows

**************End of Script******************

My TNS.Ora file is exactly same as below.

MYDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(host = abcn01p.company.net)(port =
1521))
(ADDRESS = (PROTOCOL = TCP)(host = def03v2.company.net)(port =
1521))
)
(CONNECT_DATA =
(service_name = MYDB_APP.company.net)
)
(source_route = yes)
)

యం.వి.చౌదరి

unread,
Mar 11, 2010, 3:50:32 AM3/11/10
to vishnu...@gmail.com, qtpaut...@googlegroups.com
Hi Vishunu,
 
Use the following code for connecting to Oracle database.
 
Provider=msdaora;Data Source=MyOracleDB;
User Id=myUsername;Password=myPassword;

Once you have the connection string you can now open the connection using Open method of Connection object

MyConnection.Open “Provider=sqloledb;Data Source=myServerAddress;
Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;”



--
You received this message because you are subscribed to the Google Groups "QTP Automation Experts Group" group.
To post to this group, send email to qtpaut...@googlegroups.com.
To unsubscribe from this group, send email to qtpautomatio...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/qtpautomation?hl=en.




--
సదా మీ
యం.వి.చౌదరి
Reply all
Reply to author
Forward
0 new messages