"The underlying provider failed on Open"

15,352

Solution 1

For info, there was no fix.

I ended up abandoning the VM I was having the problem on and building another (well someone else built it!)

The problem is now gone.

Solution 2

In the connection string, for the datasource, make sure to use the full descriptor rather than the entry from TNSNames.ora. For example,

`"data source=(DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=**host_name**) (PORT=**1521**)) (CONNECT_DATA= (SERVER=dedicated) (SID=**db_instance**)))"`

instead of

"data source=**my_tns_ds**"

Solution 3

I found a couple of links, thought they would be helpful to you! Hence sharing here.

On referring to this blog post, http://th2tran.blogspot.in/2009/06/underlying-provider-failed-on-open.html This section I thought of sharing with you from this blog article. "So IIS is trying to access the database under the credential 'NT AUTHORITY\NETWORK SERVICE' . I looked that the db settings via SQL Server Management Studio and, sure enough, that account is not listed as one of the users allowed to connect. So I added him. And the web app was able to connect successfully."

Try this out!

If you already have taken care of it, then please refer to the following link: MSSQL Error 'The underlying provider failed on Open'

Hope this helps!

Solution 4

Sorry if any of the above were not helpful to you. I just added them because you added SQL Server related things in [Edit]

Anyways, please check the following in SQL Server : http://www.sswug.org/articlesection/default.aspx?TargetID=44331

And in case of Oracle, please refer to the following links if they help..

http://ora-12154.ora-code.com/ http://blogs.msdn.com/b/dataaccesstechnologies/archive/2010/06/30/ora-12154-tns-could-not-resolve-the-connect-identifier-specified-error-while-creating-a-linked-server-to-oracle.aspx

Regards,

Varun Shringarpure

Solution 5

The server was not found or was not accessible.

Means that your connection string points to a server that cannot be found. Most commonly (at least for me) that is due to a wrong Sql Server name, in your case it is likely something similar. Check the

Data Source=(local) 

part of the connection string points to a connection you can access with another tool / app

(eg. the app.config of the .edmx file should point to the same place)

Share:
15,352
CompanyDroneFromSector7G
Author by

CompanyDroneFromSector7G

C# Go JavaScript jQuery LUA PHP SQL VB

Updated on June 28, 2022

Comments

  • CompanyDroneFromSector7G
    CompanyDroneFromSector7G almost 2 years

    I keep getting this error when trying to open a connection using entity framework. I can update the model from the database with no problems at all, but when I run the code in debug it gives this error. (Running on a Windows 2008 VM)

    The code fragment where the error appears looks like this:

    public partial class SpatialDatabase : global::System.Data.Objects.ObjectContext
    {
        try
        {
            using (EntityConnection conn = new EntityConnection(this.Connection.ConnectionString))
            {
                conn.Open(); // <== fails here
    
                EntityCommand cmd = conn.CreateCommand();
                ...
    

    This is connection to an Oracle database.

    This code is apparently running ok elsewhere so I have a feeling it is to do with the connection. We are using an Oracle for .NET (ODAC) driver. I have no idea whether it's 64 or 32 bit, but it works when updating the model but not when run in debug.

    (I would show additional code if I knew what to show!)

    Connection string from app.config:

    <connectionStrings>
      <add name="SpatialDatabaseContext" connectionString="metadata=res://*/SpatialDatabase.csdl|res://*/SpatialDatabase.ssdl|res://*/SpatialDatabase.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE=ds_name_here;PASSWORD=password_here;PERSIST SECURITY INFO=True;USER ID=user_id_here&quot;" providerName="System.Data.EntityClient" />
    </connectionStrings>
    

    [Edit]

    System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
    

    [/Edit]

    [Edit2]

    The above might be a red herring. I ran it again and didn;t see that error, but I did see this InnerException:

    [Oracle.DataAccess.Client.OracleException] = {"ORA-12154: TNS:could not resolve the connect identifier specified"}
    

    [/Edit2]

    [Edit 3]

    I tried to use the EFOracleProvider instead. It builds ok, but when I go to generate the entity model I get this:

    Microsoft (R) EdmGen version 3.5.0.0
    Copyright (C) 2008 Microsoft Corporation. All rights reserved.
    
    error 7001: The provider did not return a ProviderManifestToken string.
    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.
    An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
    
    Generation Complete -- 1 errors, 0 warnings
    

    I have both 32 bit and 64 bit versions of the Oracle client components installed. How do I choose whether to run 32 bit or 64 bit??

    [/Edit3]

  • CompanyDroneFromSector7G
    CompanyDroneFromSector7G over 11 years
    Thanks for the suggestions Varun - just checking: will these be relevent considering I'm running in debug in Visual Studio not IIS, and the database is Oracle not SQL Server?
  • CompanyDroneFromSector7G
    CompanyDroneFromSector7G over 11 years
    All your links seem to be SQL server related. Maybe I wasn't clear, but I'm not using SQL Server at all. Thanks for the suggestions though :)
  • CompanyDroneFromSector7G
    CompanyDroneFromSector7G over 11 years
    I'm trying to connect to an Oracle server. That message appeared once and I think it's just a red herring. I am able to rebuild the entity model from the database using the same connection details, I just can't connect at run-time.
  • Kaido
    Kaido over 11 years
    I would copy-paste the config from the working file for absolute certainty and then chase that error: ora-12154.ora-code.com