Oracle Connection string without installing Oracle client using VB.Net - oracle

I have an old VB.Net application which requires the Oracle client to be installed and uses the tnsnames.ora file on the target machine.
I have a field in My.Settings defined as the following:
Provider=MSDAORA;Data Source=MySourceName;Persist Security Info=True;Password=MyPass;User ID=MyUser
Is there a way to have it connect directly?
I tried changing the connection string using EZCONNECTION, but get an error:
Data Source=10.1.1.12:1521;Persist Security Info=True;User ID=MyUser;Password=MyPass;Unicode=True
Error message on compile:
An OLE DB Provider was not specified in the ConnectionString.
I am using Visual Studio 2019.

For connecting to an Oracle database, I recommend you install ODP.NET from NuGet. This removes any dependency on a local Oracle installation.
You can then follow the installation instructions which are included. The syntax is more or less the same as SqlCommand but you reference OracleCommand instead.

Related

Unable to connect to Oracle database from SSAS

I am attempting to create a Sql Server Analysis Services Tabular Model and am having trouble accessing an Oracle database for importing data. I am using the following:
OS
-Windows 10 Enterprise (I am administrator of machine)
Tools to create tabluar cube:
-Visual Studio Community 2022 (64 bit) - Current Version 17.2.5
-SQL Server Analysis Services 15.0.2000.5 - Developer Edition (installed on localhost, services running)
Oracle database:
Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 Production Version 21.3.0.0.0 - Developer Edition (installed on localhost), up and running and able to connect with other tools (e.g. Toad, Sqlplus, SqlDeveloper, cx_python, etc..)
I have a 64-Bit System Data Source Name created for ODBC connections, using Oracle Instant Client. This data source works just fine with other tools mentioned in the Oracle databse section above.
When creating a SSAS tabular model in Visual Studio and attemping to import a data source, I try the following:
Models
-TabularProject (my project)
-Data Sources > New Data Source > Oracle Database
At this point I get the following message:
Oracle Database
The recommended provider ('Oracle.DataAccess.Client') is not installed. You can continue with your current provider, however, it has been deprecated and may not work correctly.
and I click 'OK'.
From here, I enter the connection string of my locally hosted oracle database (localhost:1521/MY_DB.
When prompted for credentials, I select 'Database' and then enter the correct username/password to connect to my locally hosted oracle database.
Then I receive an error stating:
Unable to connect
We encountered an error while trying to connect.
Details: "An error happened while reading data from the provider: 'Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.'"
I've also tried the following method:
Models
-TabularProject (my project)
-Data Sources > New Data Source > ODBC
Then I choose my ODBC datasource for my locally hosted database (which seems to work fine for other apps) and I receive the following error:
Unable to connect
We encountered an error while trying to connect.
Details: "ODBC: ERROR [IM014] The specified DSN contains an architecture mismatch between the Driver (64-bit) and Application (32-bit)"
I have installed various Oracle Drivers including:
-64-bit ODAC: ODAC122010Xcopy_x64.zip
-64-bit instantclient basic: instantclient-basic-windows.x64-21.6.0.0.0dbru.zip
-64-bit instantclient odbc: instantclient-odbc-windows.x64-21.6.0.0.0dbru.zip
-64-bit instantclient sqlplus: instantclient-sqlplus-windows.x64-21.6.0.0.0dbru.zip
I have also tried these same steps for a remote hosted Oracle database (using both ezconnect string and a ODBC DSN) and even though the connections work just fine with other apps, it doesn't work with SSAS for some reason.
Any and all insight advice to get my SSAS tabular model connected to Oracle databases would be very much appreciated.
EDIT:
I have tried following a solution from this similar question and create a dsn, suffixed with _64, using only the 64-bit ODBC manager, yet I get the same results when trying to use that DSN with SSAS.
I have also tried the following steps, per Microsoft:
From https://learn.microsoft.com/en-us/sql/reporting-services/report-data/oracle-connection-type-ssrs?view=sql-server-ver16#64-bit-and-32-bit-drivers-for-power-bi-desktop:
2. Register ODP.NET Unmanaged Client to GAC:
C:\Oracle\odp.net\bin\4\OraProvCfg.exe /action:gac /providerpath:C:\Oracle\odp.net\bin\4\Oracle.DataAccess.dll
3. Add ODP.NET Unmanaged Client entries to machine.config:
C:\Oracle\odp.net\bin\4\OraProvCfg.exe /action:config /force /product:odp /frameworkversion:v4.0.30319 /providerpath:C:\Oracle\odp.net\bin\4\Oracle.DataAccess.dll
Yet, I still receive all errors shown above.

ORA-12154 error on server 2008

I'm moving a VB.NET 2010 app from a 32bit 2003 server to a 64bit 2008 server that connects to an Oracle 11g database, and am getting the following error message when executing it.
DefaultSource Error 2
ERROR [08004] [Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve the connect identifier specified
ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
Here's some things I've done.
Added the TNS_ADMIN environment variable to the server.
Had server management install the 64bit "Oracle driver Oracle in OraClient11g_home1". They also uninstalled the 32bit "Microsoft ODBC for Oracle" driver.
Verified I can connect to the server using SQLPlus
Updated my connection string as I use to use the 32bit "Microsoft ODBC for Oracle"
Added the database to the ODBC System DNS, and verified the connection worked.
Here's my connection string from my config file under the node.
<add name="SCHEMA_NAME"
connectionString="Driver={Oracle in OraClient11g_home1};Dbq=DATABASE_NAME;uid=USER;pwd=PASSWORD;"/>
Any suggestions to what I can try, or what needs to be changed to get this working on the new server?
I fixed the problem by changing the way I connect to oracle. I'm using the Oracle.DataAccess reference, removing the driver reference in the connection string, and rebuilding the connection using OracleConnection and oracleCommand.

ODP.NET doesn't work System.Data.OracleClient does

We are switching from the obsolete System.Data.OracleClient. I have switched all the references in the ASP.NET 2.0 code, however when I try to access the database server using ODP.NET calls I get ORA-12154: TNS:could not resolve the connect identifier specified. This works when I use System.Data.OracleClient on the same machine. Any suggestions about what is going wrong here?
You can avoid a dependency on Tnsnames.ora altogether, and go for the "independent" connection string in format:
Data Source =(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID))); User Id =myUsername; Password =myPassword;
BTW, you can look at connectionstrings.com/oracle for a quick, in-your-face list of supported connection string formats.
It sounds like your client install doesn't have your TNS names setup correctly. If you just installed ODP.NET on this machine, you probably just installed another Oracle client, and have yet to configure it.
Copy the TNSNAMES.ORA from the /NETWORK/ADMIN directory in the Oracle home where the OracleClient was installed and copy over to the new /NETWORK/ADMIN directory where ODP.NET is installed.
http://www.oracle.com/technetwork/topics/dotnet/odt-faq-085407.html#ORA-12154:_TNS:could_not_resolve_the
Christian Shay
Oracle

ORACLE Data Provider for .net OREA -12154

I am using Oracle data provider for .net to try to connect to the oracle DB, to add a ADO entity data framework model file, but i am getting the error below.
ORA-12154: TNS could not resolve the connect identifier specified
when I try to tnsping the data source name that i provide in the VS dialog i can successfully resolve it to the correct ip and host names. But for some reason the Oracle Data provider doesn't seem to be reading it from from my C:\oracle\product\10.2.0\client_1\NETWORK\ADMIN\tnsnames.ora
any ideas ?
i am using vs 2010 with the 32 bit oracle data provider from http://www.oracle.com/technetwork/topics/dotnet/index-085163.html
i can use the same TNS names on different sql client like sqlDbx it works smoothly on the same machine.
If you set a system environment variable TNS_ADMIN to the location of your tnsnames.ora file, does that help?

VB6 "Provider cannot be found."

I have a few applications written in VB6 that are all using the same connection string on the same machine. They are using the ODBC provider with the SQL Server Native Client 10.0 driver and connecting with explicit username and password.
At run-time, one of the applications throws an exception when I try to connect to the database:
3706: Provider cannot be found. It may not be properly installed.
I don't understand why this one application is having an issue when the others are working fine. The references are the same, down to the version number.
Try installing MDAC on your machine.
If you are using the program on another system and using Access you will need to download and install http://www.microsoft.com/download/en/details.aspx?id=23734 if access is not installed on the system

Resources