Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Help connecting to Oracle

Posted on 2006-06-02
6
Medium Priority
?
417 Views
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"))
        {
            conn.Open();
            try
            {
                /// 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
                oda.Fill(ds);
               
            }
            finally
            {
                conn.Close();
            }

        }


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..
0
Comment
Question by:JordanBlackler
  • 3
  • 2
6 Comments
 
LVL 35

Accepted Solution

by:
mrichmon earned 2000 total points
ID: 16819032
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 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = serverdns.name.com)(PORT = port))
    )
    (CONNECT_DATA =
      (SID = test)
    )
  )

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

Author Comment

by:JordanBlackler
ID: 16819455
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.
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 16819785
Is bmwrhs in there?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:JordanBlackler
ID: 16819805
Yeah, it is.
Do i need anything else installed on my computer.

Do i need to reference anything else.
0
 
LVL 25

Expert Comment

by:dstanley9
ID: 16820594
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"))
0
 

Author Comment

by:JordanBlackler
ID: 16823397
I added the semi-colons, but i still get the same error.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

581 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