I have an environment that uses Oracle.DataAccess.dll for Oracle 12c (ODAC is 32 bit and version is 4.122.1.0) for it's connection to the Oracle DB. In this environment, the Oracle DB is on the same machine as the ODAC (for development purposes).
Previously, I had the two working together so that my .NET application could run and access the DB. I recently had to switch out computers and reinstalled everything to my new environment. However, like always, the ODAC is being a bit stubborn.
I can connect to the DB using the following:
var conn = new OracleConnection(connectionString);
try
{
conn.Open();
conn.Close();
return "Yes";
}
catch (Exception ex)
{
return "No, because: " + ex.Message;
}
However, the application I work on opens the connection through Entity Framework instead. It uses the following:
public DatabaseContext()
: base(new OracleConnection("Data Source=localhost:1521/dbName;User Id=dbUser;Password=dbPassword;"), true)
{
}
The way the application previously ran did work on my other laptop, but this new machine I'm on throws the following error when I try to run the application:
Unable to determine the provider name for connection of type Oracle.DataAccess.Client.OracleConnection'.
My tnsNames.ora for the client is configured as follows:
dbName =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dbName)
)
)
I've gone through multiple installs of the ODAC and Oracle itself. At this point, I'm kind of out of ideas. Any help would be welcomed.
I figured out the issue. It is part of the installation that is the problem. When I installed, I skipped the Configure Provider for .NET setting. My previous documentation said to not select it, but obviously it's wrong. Selecting that setting fixed the issue immediately.
Related
Hi I'm attempting to use some of the SQL code I've written in SQL developer through a direct database connection via Excel. Unfortunately the error message I receive whenever I try is:
"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 painstakingly installed the Oracle 64bit client on my PC, so that at least, should be working. Unfortunately I've spent the best part of two days looking up solutions on the internet with no success. Does anyone know how I can force Excel to use my 64bit client or avoid this error in another way?
Update:
I believe despite my best efforts the problem is somewhere within my TNSNAMES file since I can't connect using SQL Plus either. Here's a redacted version of my Connection string. The ommitted details are correct since they are the same as I'm using for SQL Developer. Am I missing something?
DB1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521))
)
(CONNECT_DATA = (SID = SID1)(SERVER = DEDICATED)
)
)
DB2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521))
)
(CONNECT_DATA = (SID = SID2)(SERVER = DEDICATED)
)
)
Obviously, it's something small in your machine settings or configuration.
I would suggest you will look at your machine's PATH environment variable. It may refer to an older version of Oracle Server or the Oracle Client Components.
Make sure you know what you are using to access Oracle from Excel, JDBC or ODBC?
It's always the little details which drive us crazy.
Did you see any of these answers?
SQL Server 2012 connectivity to Oracle
Getting MS Office 2013 (32 bit) Excel and Access to connect to Oracle database when both 32 and 64 clients are installed
and I found this link, too complicated to copy everything to the answer:
Connect To Oracle Via ODBC Driver
And you can try connecting to Oracle with ODBC using ODAC or Oracle client, download ODAC112030_x64.zip from Oracle's website. Here's a link on how to install it SETTING UP AN ORACLE ODBC DRIVER AND DATA SOURCE
I have an excel file which was developed by my predecessor and which uses external data connection to fetch data from Oracle.
I am trying to migrate this file to a new client PC and I am getting the following error while refreshing the data:
ora 12154 tns could not resolve the connect identifier specified
The connection is established via DSN and TNS reference. The system specifications are as:
OS: Windows 7 64 bit
Oracle Client: Oracle 10.2.0 32 bit.
DSN Created in the 32 bit odbcad32.exe
TNSNames.ora is as under:
ODS_BKUP = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.146.64.132)(PORT = 1521))
)
(CONNECT_DATA =
(SID = ODSDB)
) )
I am able to do Test connection succesfully from the DSN. TNS ping also working for the server. But when I refresh the data in excel, I am getting the error.
Connection String Given in excel
DSN=MP_Prod;UID=ODS_MPMON;PWD=ODS_MPMON;DBQ=ODS_BKUP;DBA=W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;BTD=F;BAM=IfAllSuccessful;NUM
What am I missing?
same problem here and this is the solution:
https://community.spiceworks.com/topic/277836-excel-2010-ora-12154-tns-could-not-resolve-service-name
Hope this help you! =)
Ale.
I am trying to connect to Oracle ODBC for OraClient10g_home1 in System DSN.once done,i have tested the connection and it says connection successful.but when i try to import Oracle data from Excel's built-in function (Microsoft Query),it gives me the following error message.please let me know how to fix this issue.
Oracle Database Server - 32 Bit,Operating System - Windows 10(64-Bit),Excel Office 2010 (32-Bit)
in tnsnames.ora you should have an entry for database instance located in target server like :
Test=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST=target server)(PORT=1521))
)
(CONNECT_DATA =
(SID = orcl)
)
)
then tnsping Test in cmd should work fine. you will use this tns entry in your odbc.
I'm trying to connect to an Oracle Database from an Excel application and whithout a DNS. I found on a website that it's possible to use ADO, so this is why I tried to do. I'm new to this so I juste copied what I found on this website.
Here is my code so far :
Sub ADOtest()
Dim connection As New ADODB.connection
connection.ConnectionString = "UID = user1; PWD= my_pwd; DRIVER = {Microsoft ODBC for Oracle; Server= localhost; Database= orcl.my_domain;"
connection.Open
End sub
When I run this code, I get an error saying that the driver was not found.
The problem is that I have no idea of what I have to do with the driver (how to install it and configure it). Plus, I don't know which one I should use : I've read that there is a driver from Microsoft, another one from Oracle and also I've seen something about providers like msdaora.
The program will be used by many users, so I would like to choose the solution that is the lightest (not much to install on computers).
Thank you !
For COM based ADO (ADODB) you can use the OLE DB Providers.
One is from Oracle, called "Oracle Provider for OLE DB". You can download it from 32-bit Oracle Data Access Components (ODAC) and NuGet Downloads (assuming your Excel is 32-bit). The connection string would be
"Provider=OraOLEDB.Oracle;Data Source=orcl;User ID=myUsername;Password=myPassword"
The other one is from Microsoft. Please note, this provider is deprecated, you should not use it for new projects. Usually it should be available on your Windows. Be aware, like the provider from Oracle it also requires an Oracle Client to be installed on the PC! The connection string would be
"Provider=MSDAORA;Data Source=orcl;User ID=myUsername;Password=myPassword"
The data source is usually defined in tnsnames.ora file or at a LDAP server, for example:
orcl.my_domain =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(Host = localhost)(Port = 1521))
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
If you don't have such entry you can put everything into the connection string, e.g.
"Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=localhost)(Port=1521))(CONNECT_DATA=(SERVICE_NAME=orcl)));User ID=myUsername;Password=myPassword"
Perhaps you have to enclose the data source value by double-quotes ("), I am not sure.
So, in any case you would have to install an Oracle Client at all PC's.
Where is your database server hosted? In your question you say Server=localhost;, this would be quite unlikely, i.e. it is in contradiction to The program will be used by many users. I doubt everybody has an Oracle Database server installed on his local host.
I'm trying to get the state of an IIS 7.5 application pool using Microsoft.Web.Administration API, but get an exception:
System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2147020584
HResult=-2147020584
Message=The object identifier does not represent a valid object. (Exception from HRESULT: 0x800710D8)
Source=Microsoft.Web.Administration
I connect to a remote machine in a different domain using the following code:
string appHostConfigFile = "\\\\" + serverName + "\\c$\\windows\\system32\\inetsrv\\config\\applicationHost.config";
UNCAccess unc = new UNCAccess(#"\\" + serverName + "\\c$\\windows\\system32\\inetsrv\\config", <USER_NAME>, <DOMAIN>, <PASSWORD>);
server = new ServerManager(appHostConfigFile);
and then try to iterate through all application pools:
ApplicationPoolCollection applicationPools = server.ApplicationPools;
foreach (ApplicationPool pool in applicationPools)
{
Console.WriteLine(“Name: ” + pool.Name + “ State: “ + pool. State);
}
Now, the strange thing is that I do get the Name property correctly (and many other properties too) but the State property thoughts an exception.
Only when I tried connecting to the local machine (127.0.0.1), everything worked as expected.
So, can anyone tell me what I’ve been missing here? Is there any other way to connect to a remote IIS server on a machine outside of mine domain?
Thanks a lot!
I have successfully used Windows Impersonation to access a remote IIS instance using ServerManager.
using (ServerManager serverManager = new ServerManager($#"\\{computerName}\c$\windows\system32\inetsrv\config\applicationHost.config"))
{
ApplicationPoolCollection appPools = serverManager.ApplicationPools
}
This works with IIS 8 and IIS 7.5. I have not tested with other versions. I am using SimpleImpersonation (available via Nuget).