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


Help connecting to Oracle

Posted on 2006-06-02
Medium Priority
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
  • 3
  • 2
LVL 35

Accepted Solution

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 =
      (ADDRESS = (PROTOCOL = TCP)(HOST = serverdns.name.com)(PORT = port))
      (SID = test)

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

Author Comment

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.
LVL 35

Expert Comment

ID: 16819785
Is bmwrhs in there?
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

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

Do i need to reference anything else.
LVL 25

Expert Comment

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"))

Author Comment

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

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