I'm using QTP 10.
Trying to connect to Oracle DB via oracle client 10.2(windows xp).
I had prev oracle 9i & i've upgraded it to 10.2 thought it would resolve.
But still i'm getting "fatal two-task communication protocol error".
Is there any solution for that .
i see the same client version is working with windows 7 & oracle 10.2.
Appreciate your help..
I am using ADODB to connect to Oracle 10 and 11 from QTP (from VBScript in generall).
The code to connect is:
Set connection = createobject("adodb.connection")
connection.open "Driver={Microsoft ODBC for Oracle};" + _
"Server=host:1521/database_sid;Uid=username;Pwd=password;"
where:
host - is a server name where Oracle is running
1521 - is a port number (1521 is default port, but could be different on your system)
database_sid - is a SID of the database
You need to ask your database administrator for these values.
This code requires Oracle Instant Client.
You need to download proper package for your system (Win 32, Win 64 etc.) from here: http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
Unpack it to any directory and place this directory in a PATH environment variable.
and then, the code to execute queries and get results looks like this:
Set rs = createobject("adodb.recordset")
rs.open "SELECT fieldname FROM table WHERE etc.", connection
while not rs.eof
value = rs.fields( "fieldname" )
.....
loop
Related
I need to call an SQL request on an Oracle database from an Excel Sub. Here is the VB code I'm using to connect:
Set cn = New ADODB.Connection
With cn
.Provider = "MSDAORA.1"
.Properties("Data source") = "INSTANCENAME"
.Properties("User Id") = "USER"
.Properties("Password") = "PWD123"
.Open
End With
When I call it from a 32-bits Excell to a 32-bits Oracle client, it works well. But the target is a 32-bits Excel and a 64-bit Oracle client (I can't change this config). In this case I get the following error:
Oracle client and networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3.3 or later client software installation. Provider is unable to function until these components are installed.
Is it possible to call a 64-bit Oracle client from a 32-bits Excel using the same component or should I use another driver?
Any other idea is welcome.
EDIT : I can't install another Oracle client, so I can't use ODBC
I set up an ODBC connection using ODBC Data Source Administrator . I have named it "BIOTPL" connect like this:
The corresponding code is :
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Provider=OraOLEDB.Oracle;Data Source=simple_dsn;User Id=USER;Password=PASSWORD;"
But I am getting this error .
ORA-12154: TNS:could not resolve the connect identifier specified
How can I solve this error ? Please help me .
The following code works for me .
Set Conn = Server.Createobject("ADODB.Connection")
Conn.open "Driver={Oracle in OraDb11g_home1};Server=10.11.201.170; Uid=USER;Pwd=PASSWORD;"
This is how I connect to Oracle using VBscript.
ConnectionString = "Driver={Microsoft ODBC for Oracle}; CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" + DBCONN + ")(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=" + DatabaseSID + " ))); uid=" + DatabaseUser + ";pwd=" + DatabasePassword + ";"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open ConnectionString
I had a similar error when using classic ASP and Conn.Open "Provider=OraOLEDB.Oracle..." as is shown in the code above.
However, if I used Conn.Open "DSN=MyDSN;User ID=..." the connection worked.
In order to use the "Provider=OraOLEDB.Oracle..." syntax, I had to create a 32-bit application pool in IIS - create the application pool, then set Enable 32-Bit Applications = True (in advanced settings).
Note that 64-bit Windows has both 32 and 64-bit ODBC configurations. The default ODBC manager is 64-bit. Classic ASP applications can run in 64-bit mode and use 64-bit ODBC DSNs with some limitations like using Conn.Open "DSN=MyDSN;User ID=...".
If you use the Conn.Open "DSN=MyDSN..." syntax and you run in 32-bit mode, you will need to configure the DSN using the 32-bit ODBC manager. To access the 32-bit ODBC manager, run C:\Windows\SysWOW64\odbcad32.exe
The 32-bit and 64-bit ODBC manager windows look identical - there will just be different lists of DSNs that are configured.
One other tool that I found helpful is to create a file named DBConnection.udl. (The file name is not important - just the .udl suffix.) When you double-click the file, a Data Link Properties window will open and allow you to select the provider and connection info. There is also a test button to verify your connection. After setting the connection variables, close the window and open the DBConnection.udl file with a text editor (notepad.exe works) and it will display the OLEDB init string that can be used in your application.
I have a working excel macro that connects using the following connection type:
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open ( _
"User ID=userid" & _
";Password=pass" & _
";Data Source=blank.blank.com" & _
";Provider=MSDAORA.1")
I can connect in one part of my network but when I try to use the same macro on another computer I can no longer connect. My thought is there is a networking issue and I need to be "more specific". So after some googling I've come across other data connection strings that utilize IP and port name.
Driver={Microsoft ODBC for Oracle};
Server=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=199.199.199.199)(PORT=1523))(CONNECT_DATA=(SID=dbName)));
Uid=myUsername;Pwd=myPassword;
Coming from https://www.connectionstrings.com/microsoft-odbc-for-oracle/
Following Microsofts documentation then I get the following:
With cn
.Provider = "MSDAORA.1"
.ConnectionString = "Driver={Microsoft ODBC for Oracle};" & _
"Server=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=1.1.1.1)(PORT=xxxx))(CONNECT_DATA=(SID=DB)));" & _
"Uid=userid;Pwd=pass;"
.Open
End With
However I get an error: ORA-12560 TNS:Protocol adapter error
Some solutions indicate that I should restart the database, but it's running! I connect to it just fine the other way.
Does anyone have a better way of connecting "more specifically" that might help my networking problem or might be able to help me fix up my new way of connecting?
I have always used the option you originally used. The fact that it works on one machine and does not work on another indicates to me that you do not have the MSDAORA driver installed on the second computer. The machine requires that the ODBC driver exists on the machine for your code to function.
Go to ODBC and make sure you can create a test connection via the ODBC panel on the second machine to make sure ODBC is functional for the MSDAORA driver.
I see there is no test connection when using Microsoft ODBC for Oracle. There is for the Oracle driver. One way to test it is to open MS Access and create a linked table, using the Microsoft ODBC connection you created. It will prompt you for a password and if it succeeds you will link the table, and know it is working, or it will give you an ODBC error, and you will know it is not.
Or you could use the Oracle driver, which would require installing the Oracle Client driver, and changing your connection information to reflect that driver instead of the MS one.
This works fine for me:
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open ( _
"User ID=userid" & _
";Password=pass" & _
";Data Source=blank.blank.com" & _
";Provider=MSDAORA.1")
I just replaced the hard drive on my Windows 7 machine (my development computer). I did not have any issues with this working on the old hard drive, but I think I remember I had to change something or install something, but I do not remember.
The following code works perfectly on my live machine (Windows 2003 with IIS6).
OracleConn = "Provider=MSDASQL.1;Persist Security Info=True;User ID=TheUID;Password=ThePW;DSN=TheDB;DBQ=ORA_PRD1;"
SqlStr = "SELECT * FROM TestTable WHERE Somefield = 'Something'"
Set Objrs = Server.CreateObject("ADODB.RecordSet")
Objrs.Open SqlStr, OracleConn, adOpenStatic, adLockOptimistic,adCmdText
While Not Objrs.EOF
Response.Write "Some Stuff and whatever <br>"
Objrs.MoveNext
Wend
Objrs.Close
Set Objrs = Nothing
When I run it, I am getting the following error:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
I did create a .udl file to get the connection string and to test the database connection and it works fine. I also have an app on my computer that uses the same ODBC drivers to connect to the same database and it works fine.
I dont have any issues connecting to an Access database at all. Connecting to Oracle seems to be the only issue I am having.
What are the steps to be taken to use oracle instant client to connect from excel to oracle database. I have the unzipped basic instant client folder. The OS used is Windows XP.
Here is my connection string:
strConnection = "Driver={Microsoft ODBC for Oracle};Server=servername;
Uid=username;Pwd=password;"
I have done the following :
Set environment path for ORACLE_HOME, PATH and TNS_ADMIN
In HKEY_LOCAL_MACHINE\SOFTWARE I have create a key with name Oracle with String name ORACLE_HOME and set the variable..
But when I try to connect from Excel I am getting error as oracle client and networking not found.
Install the ODBC supplement?