locked
Oracle connection Issue ("ORA-12541: TNS:no listener") RRS feed

  • Question

  • Hi

    I am new to oracle database. I can connect Oracle database from SQL Plus but when I try using C# code it says that "ORA-12541: TNS:no listener". How it's possible to connect from C# code. Here is my code,

                       OracleConnection ORAcon = new OracleConnection("DATA SOURCE=server;USER ID=XXX;PASSWORD=XXX;";);

                       OracleCommand ORAcmd = ORAcon.CreateCommand();                   
                        ORAcmd.CommandText = "select query";
                        ORAcon.Open();

    Error occured when connection was open in above code. Please help me to resolve this problem.

    Thanks & Regards,

    Rajkumar.


    • Edited by RAJ KUMAR .R Tuesday, November 12, 2013 7:46 AM
    • Moved by Eason_H Wednesday, November 20, 2013 2:23 AM
    Tuesday, November 12, 2013 7:45 AM

Answers

  • I see. You know that the Oracle database is from Oracle, not Microsoft? Go to their forums.

    The error message tells you, that you don't have (correctly) setup the drivers on your client machine.

     
    • Proposed as answer by Eason_H Wednesday, November 13, 2013 2:34 AM
    • Marked as answer by Eason_H Wednesday, November 20, 2013 2:23 AM
    Tuesday, November 12, 2013 8:57 AM

All replies

  • I see. You know that the Oracle database is from Oracle, not Microsoft? Go to their forums.

    The error message tells you, that you don't have (correctly) setup the drivers on your client machine.

     
    • Proposed as answer by Eason_H Wednesday, November 13, 2013 2:34 AM
    • Marked as answer by Eason_H Wednesday, November 20, 2013 2:23 AM
    Tuesday, November 12, 2013 8:57 AM
  • Yes, if you can't solve this issue you should refer to the appropriate Oracle forums. But, because this looks very much like a connection string problem, this site is generally helpful in those cases: connectionstrings.com

    I recommend comparing your connection string with the examples listed on that site. Maybe, it already helps to get over that issue.

    wizend

    Tuesday, November 12, 2013 2:29 PM
  • Check the platform you're building against.  If it is Any CPU and you're running x64 Windows then you'll run into issues.  It is generally recommended that you only run a single version of the Oracle client and most people run the x86 version.  As such an x64 app won't find the drivers.  Verify whether you installed x86 or x64 and then ensure your .NET app is built using the same platform.

    Michael Taylor
    http://msmvps.com/blogs/p3net

    Tuesday, November 12, 2013 3:21 PM
  • Hi Michael,

    The error message comes from the driver. He isn't capable of resolving the TNS service name.

    Tuesday, November 12, 2013 3:43 PM
  • TNS entries are stored in the Oracle Home directory.  The x64 version will have a potentially different list than the x86 list.  Hence using SQL-Plus with x86 may work but a .NET app with x64 will not.

    Tuesday, November 12, 2013 4:06 PM