locked
ORA-12154: TNS:could not resolve service name from web application only RRS feed

  • Question

  • User-1556678718 posted

    Hello,

    When I'm trying to open a connecttion from a web application I am getting the message "ORA-12154: TNS:could not resolve service name". When I'm opening the connection from a windows application with the same connection string everything is working fine so I assume the tnsnames should be fine. Also I can access the database with the Toad and SQL Developer. I am using Visual Studio 2008. Please help 

    Thursday, May 10, 2012 2:45 AM

All replies

  • User269602965 posted

    in web config

    show your connection string

    in code behind web page

    show your Oracle connection code

    Thursday, May 10, 2012 5:33 PM
  • User-1556678718 posted

    Please be more specific hoe to show the connection string in web config

    i have something like:<connectionstrings><add name="Oraceconnstr" connectionstring="theconnectionstring"/> with the same connectionstring i am connecting from a windows application

    I am using OracleConnection con= new OracleConnection(configuration.Oracleconstr) but here i tryed to type in the connection string still no sucess.

    I am using win7 X64 and oracleclient x86

     

    Friday, May 11, 2012 9:40 AM
  • User269602965 posted
    In web.config
    
    <connectionStrings>
    	<add name="OraConnStr" connectionString="Data Source={DatabaseName};Persist Security Info=True;User Id={SchemaName};Password={password}" providerName="Oracle.DataAccess.Client">
    	</add>
    </connectionStrings>
    
    In code behind page, an example of sending update information to database
    
    Imports System.Xml.Linq.XElement
    
    Dim DateTimeStamp As Date = DateTime.Now
    Dim TicketSeq As Decimal = 1
    
    Dim connectionString As String = ConfigurationManager.ConnectionStrings("OraConnStr").ConnectionString
    ' update help ticket information into database '
    Try
      Dim SQL = <SQL>
                  UPDATE {YourSchemaName}.HELP_TICKET
                  SET TICKET_TIMESTAMP = :TICKET_TIMESTAMP
                  WHERE TICKET_SEQ = :TICKET_SEQ
                </SQL>
      Using conn As New OracleConnection(connectionString)
        Using cmd As New OracleCommand(SQL.Value, conn)
          cmd.Parameters.Clear()
          cmd.Parameters.Add("TICKET_TIMESTAMP", OracleDbType.Date, DateTimeStamp, ParameterDirection.Input)
          cmd.Parameters.Add("TICKET_SEQ", OracleDbType.Decimal, decTicketSeq, ParameterDirection.Input)
          conn.Open()
          cmd.ExecuteNonQuery()
        End Using
      End Using
    Catch ex As Exception
    End Try
    

    Saturday, May 12, 2012 9:34 AM
  • User-1556678718 posted

    Yes I have the same and it is crashing on conn.Open(); with the valid connection string returning the message posted previosly. Can this be because I have x64 windoes 7 and oracle drivers are x86? 

    Monday, May 14, 2012 1:39 AM
  • User269602965 posted

    In WIndows 7 64 bit development environment.

    You can install Oracle 11g 64-bit database,

    but you must also install the Oracle ODP.NET (latest version is fine) as 32-bit using the ODP.NET installer option to install the CLIENT,

    and you install the 32-bit client in a new Oracle Home folder within the Oracle Base folder.

    And your VS2010 app must be forced into x86 compilation (not AUTO).

    Many folks in this forum also go to the Client Install home directory ODP.NET folder, find the appropriate OracleDataAccess.dll (2.0 or 4.0)

    and copy the DLL to the project /BIN folder, with a local reference to the DLL on compilation.

     

    Monday, May 14, 2012 9:22 AM
  • User269602965 posted

    ORA-12154: TNS:could not resolve service name from web application only

    This error is rather generic with many causes.

    One often overlooked cause is firewall (hardware and software firewalls) not being open to TCP Port 1521 (the default listener port for Oracle, or if you change that, what ever port you set the listener too),

    If Oracle is running in Windows, check that the Oracle listener service is started, sometimes it just does not start automatically (never been able to get an answer from Oracle tech support on that); and must be started manually.

    In tnsnames.ora, I like to use static IP of hosts and not host names.

    WIndows installation guide has specific environmental variables for Oracle that are recommended.

     

    Monday, May 14, 2012 9:32 AM