Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
connect oracle to QTP
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
hi,
in my application i want to connect oracle database to QTP and execute the query.i tried with this code but failed to establish connection.

what all add-ins should be installed to connect database to QTP?

Code:
set conn=Createobject("ADODB.Connection")
Srvname="Driver={Microsoft ODBC for Oracle}:Server=DBserver,UID=abcd,Password=xyzz"
conn.open Srvname
Set Rec = CreateObject("ADODB.Recordset")
SQL="select PR_CODE  from SCHED"
Rec.open SQL ,conn


thanks
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Try this:
Code:
Srvname="Driver={Microsoft ODBC for Oracle};Server=DBserver;UID=abcd;Password=xyzz;"
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
NO,It will not work if we use semicolon at the end .The other script works now .
Thanks for your reply.
Regards,
Sherin G
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,

I also have some problems, setting up a database connection to an oracle server.
I googlet a lot, but I just can't get it done...
My code is like this:

Code:
set conn=Createobject("ADODB.Connection")
Srvname="Driver={Microsoft ODBC for Oracle}:Server=xyz.intranet.com,UID=abcd,Password=xyzz"
conn.open Srvname
...
After the conn.open, the script stops having an error.

The errror I get with this code is:
"[Microsoft][ODBC Driver Manager][Oracle]ORA-12504: TNS: listener was not given the SID in CONNECT_DATA"

I'm a bit confused about the connection-string, because I did not find a way to specify the connection-port and the database used for this connection. I tried around with adding "SID=myDB" or "Data Source=myDB" and "Port=123". But it did not work...
With adding "SID=myDB", the error-message is:
"[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed".

I have installed OracleXEClient on my computer, but as I said, the db is running on a another server in the intranet. My PC on which also QTP is running, has Windows XP as OS.

Many solutions I found in the internet meant to specify the connection in the tnsnames.ora-file. But, honestly, I can't find such a file.

Is there a way to get the oracle-connection running without specifying some tnsnames.ora-file? Do I have to install some other version of oracle?
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,
You can do like this.
1)Create a Data Source name by following these steps.
Control Panel...>Administrative Tools...>Data Sources(ODBC)
Click on Add...>Select Driver Microsoft ODBC For Oracle Database
and follow the screens and then use the following code.
2)Paste the following Code in the QTP Expert View Window

Connect to the flight 32 database
Code:
Set Conn = CreateObject("ADODB.Connection")
Set Rs = CreateObject("ADODB.recordset")

Conn.Open("DSN=dsnname")
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Somisays,

Thanks for the Reply.
I tried to do what you posted, but the problem was again, that I do not know what to do about this TNS-stuff...
When adding a Data Source with the Oracle driver, a TNS-Service Name is required. Again I googled for this, but ... everybody just tells to add something to the file tnsnames.ora...
As I already mentioned above, I do not have any .ora-file on my system. I think I need something more to install, but I have no idea what?
I made some connections to mySQL, Access and MSSQL databases in the past, but never to oracle. So I appreciate any help about what I need to add to my system in order to make it work.

Thanks!
Reply
#7
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,
Have you installed oracle or not.If so Which version?
Would you able to connect to SQLPlus or not?
Reply
#8
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,

I have OracleXE installed on my system. The database, I try to connect to is on a different server.

I'm also not able to connect with SQLPlus. It gets the same error.
Do I need to install another version of Oracle?

Thanks in advance!
Reply
#9
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,
Ok I resolved my problem.
I had installed OracleXEClient instead of OracleXE. The client does not have any tnsnames.ora-files ...
With OracleXE, the solution you gave me with adding a Data Source works fine. :-)
Thank you very much!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Getting error while connecting from qtp to oracle sql developer. Ritanjali Pradhan 1 3,193 09-26-2014, 02:06 PM
Last Post: vinod123
  Not able to connect to Oracle SQL Developer Paras Singh 0 6,773 05-30-2013, 01:25 PM
Last Post: Paras Singh
  Choosing Add-ins in QTP When Oracle forms or other IDEs used in web based application QTPBeginer 0 2,613 03-27-2013, 11:06 PM
Last Post: QTPBeginer
  Connect to QC ravi.gajul 3 14,712 09-18-2012, 12:39 PM
Last Post: SrinuKodi
  QTP API to connect to Performance Center(ALM) as_srini 3 5,732 06-14-2012, 09:14 PM
Last Post: Ankesh

Forum Jump:


Users browsing this thread: 5 Guest(s)