none
Cannot connect to an Oracle database in a Test project RRS feed

  • Question

  • I am experiencing a frustrating problem that is only occuring in a unit test project. When I try to open a connection to an Oracle database I receive the following error: System.Data.OleDb.OleDbException: ORA-12154: TNS:could not resolve the connect identifier specified.

    I can run the exact same code in a console app or anywhere other than the unit test and connect to the database. I already resolved a 64bit/32bit compatibility issue. That issue was due to only having the 64bit Oracle client installed but the unit test environment requires 32 bit. I installed the 32bit oracle client to resolve that issue. To verify that worked, I targeted my console app for x86 and still ran successfully. I have verified many times that my tnsnames.ora file is correct and that the TNS names resolve. The problem is only occurring in my unit tests which were created using Visual Studio 2008 unit test.

    As the error indicates, I am using the OleDb provider. My connection string looks like: Provider=OraOLEDB.Oracle.1;User Id=username;Password=password;Data Source=tnsalias;.

    Why can it not resolve the TNS name from the unit tests?

    Thursday, May 20, 2010 12:31 AM

All replies

  • Hello,

     

    Welcome to ADO.NET Managed Providers forum!

     

    The problem is really strange to me.  I am not an expert of VS unit test, but the difference I know between a unit test app and the console app without the unit test environment is that the unit test is running under the process VSTESTHOST.EXE.   So the corresponding config file would be VSTESTHOST.EXE.CONFIG.   Are the connection strings the same in the different environment?   

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, May 20, 2010 8:30 AM
    Moderator
  • Hi,

     

    I am writing to check the status of the issue on your side.  Would you mind letting me know the result of the suggestions? 

     

    If you need further assistance, please feel free to let me know.   I will be more than happy to be of assistance.

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, May 24, 2010 1:29 AM
    Moderator