locked
Unable to connect to Oracle database in my ASP.NET application RRS feed

  • Question

  • User934878745 posted

    Hello All..!!

    I've developed window & asp web applications in VS 2008 in windows server 2008, which can connect to Oracle database using 10g client (10.2.0.1.0).

    Now I want to move my applications to VS 2015 in Windows server 2012 R2, which connects to the same Oracle database using 10g client (10.2.0.1.0).

    After moved the web application, I hosted it in IIS @ server 2012 R2. When I try to access the web application, it's showing this error "System.Exception: System.Data.OracleClient requires Oracle client software version 8.1.7 or greater." at the time of opening the db connection ( connection.Open() ).

    When I try to open the application in VS 2015 and debug it, I'm getting this error "System.Data.OracleClient.OracleException: ORA-12154: TNS:could not resolve the connect identifier specified" at the time of opening the db connection ( connection.Open() ).

    And I've moved several window application too. I'm able to build and run the application if I set the platform target to x86.

    If the platform target to 'Any CPU', I'm getting the below error.

    An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.OracleClient.dll

    Additional information: 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.

    Pls help me out on what I'm missing...!!!

    Wednesday, April 25, 2018 6:48 AM

All replies

  • User632428103 posted

    Hello aruncody47,

    i haven't been developed since many years with oracle but normally you need to install some component of the machine, need to import also oracle.dataaccess.dll

    read perhpas this :

    https://docs.oracle.com/cd/B28359_01/appdev.111/b28844/using_aspnt.htm#BABBFHIG

    Wednesday, April 25, 2018 7:06 AM
  • User347430248 posted

    Hi Aruncody47,

    Your description is little bit confusing.

    You had mentioned many errors and then you talk about windows application.

    If we talk about first error,"System.Data.OracleClient requires Oracle client software version 8.1.7 or greater."

    You can try to update your Oracle with 8.1.7 or higher version.

    For second error,"System.Data.OracleClient.OracleException: ORA-12154: TNS:could not resolve the connect identifier specified"

    For this error following can be the causes.

    1. SQL Server (and oracle net libraries) is not able to get the TNS alias from tnsnames.ora file.
    2. Something is wrong with the way the alias is created in the tnsnames.ora file (incorrect syntax)
    3. TNS alias could not be resolved into a connect descriptor

    You can refer steps mentioned in the link below to resolve the error.

    “ORA-12154: TNS: could not resolve the connect identifier specified” error while creating a linked server to Oracle

    Other thing you had mentioned that,"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 suggest you to install the supported components and use the same bit ness for it, Otherwise it will create an issue.

    Regards

    Deepak

    Thursday, April 26, 2018 6:00 AM
  • User934878745 posted

    Hi Deepak,

    Thanks for the reply.

    I've moved my window & web applications to new server which has VS 2015 and Oracle 10g client (10.2.0.1.0) in Windows server 2012 R2 (64-bit).

    1. "System.Exception: System.Data.OracleClient requires Oracle client software version 8.1.7 or greater." I'm getting this error when I hosted the web application in IIS. But I've already installed Oracle 10g client (10.2.0.1.0).
    2. "System.Data.OracleClient.OracleException: ORA-12154: TNS:could not resolve the connect identifier specified." I'm getting this error when open the same web application in VS 2015 and debug it.
    3. "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'm getting this error while running my window application in platform target = Any CPU
    4. I'm not getting any error while running the same window application in platform target = x86

    1 & 2 points related to the same web application. 3 & 4 points related to the same window application.

    The Oracle client installed remains same for all the above said scenarios.

    Hope this explains my problem clearly.

    Thursday, April 26, 2018 6:35 AM
  • User347430248 posted

    Hi ArunCody,

    This forum only handles ASP.NET related issues. So lets focus on it.

    Did you try to follow the steps mentioned in the link?

    Does that help?

    If you did not follow it then I suggest you to follow it and let us know about the result.

    Also check that whether you had installed the correct driver for Oracle or not.

    It is possible that incorrect drivers are causing the issue.

    Regards

    Deepak

    Friday, April 27, 2018 6:25 AM
  • User1120430333 posted

    "System.Data.OracleClient.OracleException: ORA-12154: TNS:could not resolve the connect identifier specified." I'm getting this error when open the same web application in VS 2015 and debug it.

    The TNS is bad,  and you need to figure out what the TNS configuration should be now on the new machine.  

    "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'm getting this error while running my window application in platform target = Any CPU

    32bit drivers don't work in 64bit environment.

    I'm not getting any error while running the same window application in platform target = x86

    Well,  the 32bit drivers work on X86, since x86 is a 32bit environment. So find a 64bit driver or install the 32bit driver and run application in 32bit mode x86, including your Web application code and setting the Application Pool that is hosting your Web application to 32bit mode.

    http://www.samlogic.net/articles/32-64-bit-windows-folder-x86-syswow64.htm

    Monday, April 30, 2018 12:07 AM
  • User1459274329 posted

    Hello aruncody47,

    i haven't been developed since many years with oracle but normally you need to install some component of the machine, need to import also oracle.dataaccess.dll

    read perhpas this :

    https://docs.oracle.com/cd/B28359_01/appdev.111/b28844/using_aspnt.htm#BABBFHIG

    helpful!

    Tuesday, May 1, 2018 10:59 AM