Connecting to Oracle from Excel - oracle

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

Related

rs.update fails on Win Server 2016 - Microsoft][ODBC driver for Oracle]General error

I've moved a legacy Classic asp app to Windows server 2016
in large part to resolve TLS 1.0 browser issues. The website works just like it should except for one problem. Updating a DB record fails.
I've set up syswow64 DNS and used a 32 bit Oracle 11g express install on the webserver to talk with the Oracle 11g standard DB. Everything seems to be fine with the application except when updating a sequence table. The code worked fine previously on windows server 2008.
rs.open sql, cn, adOpenDynamic, adLockPessimistic, adCmdText
If CheckNativeError(cn, SQL, Current_Sub_name) then
fGet_Next_SEQ_ID = ""
exit function
END IF
Opening and reading the recorset works and now need to update the
rs("NEXT_SEQ") = NEXT_SEQ (next seq = 222250)
rs.Update
Receives the following error.
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC driver for Oracle]General error
I'm thinking it is unable to update possibly by a driver issue involving a TLS 1.2 issue but I cannot find the answer why or what to do about it. Other settings for the website are correct, enable 32-bit code.. app pool, etc.
32 bit Driver used: Microsoft ODBC for Oracle
Switching to the Oracle XE driver instead of the Microsoft for Oracle driver fixed the issue. I've tested all the pages and it works fine. Looks like the Microsoft 32 bit driver will not be useful any longer with the TLS 1.2

UFT connection with Redshift

We are getting error while trying to connect UFT with Redshift:
Dim dbConnection
Srvname = "Driver={Amazon Redshift (x64)};Server=serverName; Database=DBName; UID=****; PWD=****; Port=****;"
Set dbConnection = CreateObject("ADODB.Connection")
dbConnection.Open Srvname
Error coming as:
Datasource name not found and no default driver specified.
But with all same credential we can able to connect redshift with "SQL Workbench".
SQL Workbench is using a different Connector (most probably JDBC or some other technology). The ADODB.Connection Object is trying uses the ODBC Drivers installed for the Operating System, so first things frist you need to install the ODBC Driver.
After this is don, depending on your credential management policy, you may need to simply use the proper Connection String or configure stuff in the ODBC wizard of Microsoft Windows.
SQL Workbench uses Amazon Redshift JDBC compatible driver. Try downloading ODBC driver. Follow the below link

Migrating VB6 code to use 64-bit ODBC DSN

I have a legacy VB6 application, which is making ODBC connections to a proprietory 3rd party database using ODBC.
Dim con As Object ' New ADODB.Connection
Set con = CreateObject("ADODB.Connection")
con.Open ("DB64bitDSN")
It used to work until now. Recently they have installed 64 bit version of the 3rd party database. The 3rd party database automatically creates a 64 bit ODBC DSN during installation, and the same is working when I connect using Excel's Data Connection Wizard, and using ODBC DSN as the data source.
But my code is giving error:
Error Description: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
Error Source: Microsoft OLE DB Provider for ODBC Drivers
How should I change my code to make it work? Do I need to add a reference to any library and modify my code?
Thanks.
You do not need to change the code. You need to ask "them" to create a 32-bit ODBC DSN. VB6 requires this in order to connect.
There is more information on this Microsoft page.
Extract from the page
To manage a data source that connects to a 32-bit driver under 64-bit
platform, use c:\windows\sysWOW64\odbcad32.exe.

Connection string to connect to remote Oracle 11g

I need to connect to a remote Oracle server from VBA. I do not want to install any additional drivers or software to connect as I need to distribute the Excel to the team.
I tried several connection strings giving errors like SQL_HANDLE_ENV failed. or Oracle client and networking components not found. or when use OraOLEDB.Oracle I get Provider not found.
Connection strings tried so far:
"Driver={Microsoft ODBC for Oracle}; CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hostname)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=servicename))); uid=username; pwd=Password;"
"PROVIDER=MSDAORA.Oracle;DATA SOURCE=hostname;USER ID=username;PASSWORD=Password"
"PROVIDER=MSDAORA;DATA SOURCE=hostname;USER ID=username;PASSWORD=Password"
"Driver={Oracle in OraClient11g_home1};Dbq=servicename;Uid=username;Pwd=Password;"
"Provider=OraOLEDB.Oracle;Data Source=hostname;User Id=username;Password=Password;"
There are some pre defined drivers in windows i suppose. But does it not work for oracle? I use windows 8
Any help greatly appreciated..
I did some more research and came across ODP.net. So the conclusion i think is either use Oracle Instant Client or ODP.net. But i am no sure if any .net Application like ODP.net will work without .Net framework. Please let me know if anyone came across this.
Almost every provider needs an Oracle Client installed. Exceptions are JDBC which is Java and does not work in VBA/Excel and the ODP.NET Mananged Driver. However, ODP.NET Mananged Driver is a .NET assembly and they are not working with COM which is used in VBA/Excel. You would have to write your own wrapper for it.
The .NET framework is part of every Windows installation, there should be no concerns.
btw, did you add Reference for Microsoft ActiveX Data Objects ... to you VBA project?
Looks like you cannot pass by the Oracle Instant Client.
Try this:
Provider=MSDAORA.1;Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = SERVER0123)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = PRODDB)));User Id=USER_ID;Password=USER_ID_PASSWORD
Obviously you need to replace the server, User ID and Password.

Fatal two-task communication protocol error in oracle 10 g

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

Resources