ORA-12154: TNS:could not resolve service name

Last post 07-04-2005 9:37 AM by dantheman13. 8 replies.

Sort Posts:

  • ORA-12154: TNS:could not resolve service name

    06-29-2005, 3:40 PM
    • Member
      110 point Member
    • dantheman13
    • Member since 06-29-2005, 3:29 PM
    • Posts 22
    Hello all,
    I am very new to Oracle and I keep getting this error in .Net and I don't know why...
    I am using Oracle 8.1.7, C# and using System.Data.OracleClient
    I selected OracleDataAdaptor from the toolbox and created a new connection and tested it and it was successful.
    I built my program and there are no errors but when the page loads I get the error mentioned in the subject heading.
    It says the error occurs at conn.Open();
    Does anyone know how to go about and try to fix this error?
    By the way here is that section of code:

    protected System.Data.OracleClient.OracleDataAdapter oracleDataAdapter1;
    protected System.Data.OracleClient.OracleCommand oracleSelectCommand1; // Selects all the columns in the db
    protected System.Data.OracleClient.OracleCommand oracleInsertCommand1;
    protected System.Data.OracleClient.OracleConnection conn; // Tested connection and it worked
    protected System.Web.UI.WebControls.ListBox nameListBox;

    private void Page_Load(object sender, System.EventArgs e)

    {

    using(conn)
    using(oracleSelectCommand1)

    {

    oracleSelectCommand1.Connection = conn;

    conn.Open();

    OracleDataReader reader = oracleSelectCommand1.ExecuteReader();

    while(reader.Read())
       nameListBox.Items.Add(
    new ListItem(reader.GetString(0)));

    reader.Close();

    }

    Thanks.

    DAN

  • Re: ORA-12154: TNS:could not resolve service name

    06-29-2005, 5:04 PM
    • Participant
      1,873 point Participant
    • dweezil
    • Member since 11-06-2002, 3:04 PM
    • San Francisco, CA USA
    • Posts 395
    I don't see a connection in string your code.

    You have to pass the connection string as an argument to the connection object, or else it does not know what Oracle instance to open.

    --dweezil

    SELECT * FROM users WHERE clue = 'yes';

    Records found: 0
  • Re: ORA-12154: TNS:could not resolve service name

    06-29-2005, 5:20 PM
    • All-Star
      26,551 point All-Star
    • Caddre
    • Member since 06-23-2003, 9:53 AM
    • Indy
    • Posts 5,308

    I also don't think you can use  OracleDataAdapter to connect to Oracle 8.1.7, you have to use Microsoft  OracleAdapter because OracleDataAdapter can only be used by Oracle 9i.  Try the links below for connectionstring.  Hope this helps


    http://www.carlprothman.net/Default.aspx?tabid=86#OracleNETDataProvider

    Kind regards,
    Gift Peddie
  • Re: ORA-12154: TNS:could not resolve service name

    06-30-2005, 9:04 AM
    • Member
      110 point Member
    • dantheman13
    • Member since 06-29-2005, 3:29 PM
    • Posts 22
    Hi,
    from what I have been reading here and elsewhere I think there might be a problem with my permissions with asp.net and oracle. Where do I go on my computer to find this information and how would I go about changing the permissions if that is indeed the problem.
    I am using Oracle 8.1.7 and Visual Studio .NET 2003 on a Windows 2000 system.
    Thanks


    DAN
  • Re: ORA-12154: TNS:could not resolve service name

    06-30-2005, 10:18 AM
    • Participant
      1,873 point Participant
    • dweezil
    • Member since 11-06-2002, 3:04 PM
    • San Francisco, CA USA
    • Posts 395
     dantheman13 wrote:
    Hi,
    from what I have been reading here and elsewhere I think there might be a problem with my permissions with asp.net and oracle. Where do I go on my computer to find this information and how would I go about changing the permissions if that is indeed the problem.
    I am using Oracle 8.1.7 and Visual Studio .NET 2003 on a Windows 2000 system.
    Thanks


    DAN

    Check that the ASPNET account and the Authenicated Users group both have Read & Execute permissions on the Oracle directory.
    Right click the Oracle directory and select Properties, then click on the Security tab to view the permissions.
    --dweezil

    SELECT * FROM users WHERE clue = 'yes';

    Records found: 0
  • Re: ORA-12154: TNS:could not resolve service name

    06-30-2005, 12:17 PM
    • Member
      110 point Member
    • dantheman13
    • Member since 06-29-2005, 3:29 PM
    • Posts 22
    Hi,
    To the oracle folder I added asp.net, authenticated users, Internet Guest Account and Launch IIS Process Account users and gave them all full control. But I still get the same error. Also I took the same code I mentioned above and used it in a Windows application instead of a ASP.NET Web Application and I accessed the database with no problems...
    So does anyone have any suggestions on what to do now?
    Thanks.


    DAN
  • Re: ORA-12154: TNS:could not resolve service name

    06-30-2005, 2:34 PM
    • Participant
      1,873 point Participant
    • dweezil
    • Member since 11-06-2002, 3:04 PM
    • San Francisco, CA USA
    • Posts 395
     dantheman13 wrote:
    Hi,
    To the oracle folder I added asp.net, authenticated users, Internet Guest Account and Launch IIS Process Account users and gave them all full control. But I still get the same error. Also I took the same code I mentioned above and used it in a Windows application instead of a ASP.NET Web Application and I accessed the database with no problems...
    So does anyone have any suggestions on what to do now?
    Thanks.


    DAN

    Make sure ASPNET and Authernicated Users permissions are propagating down to the BIN folder. 

    If this doesn't fix the problem post your tnsnames.ora file.
    --dweezil

    SELECT * FROM users WHERE clue = 'yes';

    Records found: 0
  • Re: ORA-12154: TNS:could not resolve service name

    06-30-2005, 5:56 PM
    • Participant
      1,460 point Participant
    • rponton
    • Member since 07-10-2002, 2:13 PM
    • Posts 292
    The Oracle Universal(ly hated) Installer does stupid things with the permissions on the folders.

    Verify that the local ASPNET account (might as well just give it to Everyone, IMHO) has Read/List/Execute permission on ORACLE_HOME, ORACLE_HOME/bin, *and* ORACLE_HOME/network/admin.  Somehow, all of those folders can end up with seperate permissions.  Further, depending on how you copy the TNSNAMES.ORA file around, it can end up with its own unique set of permissions, so check that too.

  • Re: ORA-12154: TNS:could not resolve service name

    07-04-2005, 9:37 AM
    • Member
      110 point Member
    • dantheman13
    • Member since 06-29-2005, 3:29 PM
    • Posts 22
    It works!!
    What was missing was giving the permissions to the tnsnames.ora file because even though I gave the proper permissions to the whole oracle file you still have to add permissions to this file individually as well. After I added permissions to that file no more errors! Hooray!
    Thanks to everyone who helped me!

    DAN
Page 1 of 1 (9 items)