Help connecting to Oracle

Posted on 2006-06-02
Last Modified: 2008-02-01
I'm new to all of this. This is for a web application.
I believe the problem is with my data source. I'm not exactly sure what my data source should be. Is it the server name plus database name?

Here is a code i found:

using (OracleConnection conn = new OracleConnection("Data Source=??? User Id=userid Password=password;Integrated Security=yes"))
                /// Create CommandObject and executes the select-statement
                OracleCommand cmd = new OracleCommand("SELECT * FROM dw_time_analysis");
                DataSet ds = new DataSet();
                OracleDataAdapter oda = new OracleDataAdapter(cmd);
                /// Fill the dataset with the result of the SQL statement


This is the error i get:

ORA-12154: TNS:could not resolve the connect identifier specified
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OracleClient.OracleException: ORA-12154: TNS:could not resolve the connect identifier specified

Source Error:
Line 17:         using (OracleConnection conn = new OracleConnection("Data Source=bmwrhs User Id=notesdb Password=cricket05;Integrated Security=yes"))
Line 18:         {
Line 19:             conn.Open();   //in red font
Line 20:             try
Line 21:             {
Source File: c:\VacationFormOracle\Default.aspx.cs    Line: 19

Thanks guys..
Question by:JordanBlackler
    LVL 35

    Accepted Solution

    If you are using 10G client then you need to actually create a TNS file taht points to the server.

    Basically in this directory: C:\oracle\product\10.2.0\client_1\NETWORK\ADMIN\
    You need a file called tnsnames.ora

    The contents looks like:

    servername =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = = port))
        (CONNECT_DATA =
          (SID = test)

    Basically you need to fill in all of the lowercase sections with your information.

    Author Comment

    I just got tnsnames.ora file that points to all the servers.
    I stuck it in that directory and i still get the same error message.
    LVL 35

    Expert Comment

    Is bmwrhs in there?

    Author Comment

    Yeah, it is.
    Do i need anything else installed on my computer.

    Do i need to reference anything else.
    LVL 25

    Expert Comment

    I know nothing about Oracle, but it looks like you're mising some semi-colons (between Data Source, User ID, and Password)

    using (OracleConnection conn = new OracleConnection("Data Source=bmwrhs; User Id=notesdb; Password=cricket05;Integrated Security=yes"))

    Author Comment

    I added the semi-colons, but i still get the same error.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now