?
Solved

Problem Connecting to Oracle from .NET3.5 application

Posted on 2009-07-13
18
Medium Priority
?
1,702 Views
Last Modified: 2012-06-21
Hello,
I have a NET3.5 web application which is trying to connect to a Oracle10g Db.
The connection string is as follows:
<add key="connectionstring2" value="Driver={Microsoft ODBC for Oracle};Server=Test;Uid=Test1;Pwd=Gold;"/>
Iam using the System DSN to connect to.
But I get the following exception when I try to open a connection.
+            ex      {"ERROR [08001] [Microsoft][ODBC driver for Oracle][Oracle]ORA-12154: TNS:could not resolve the connect identifier specified\r\nERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed\r\nERROR [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr)."}      System.Exception {System.Data.Odbc.OdbcException}

Any Inputs highly appreciated.
Thanks.
0
Comment
Question by:Star79
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 2
  • +1
18 Comments
 
LVL 28

Expert Comment

by:strickdd
ID: 24842828
Sounds like you are either specifying the wrong drive in the connection string or you have the wrong driver installed.
0
 

Author Comment

by:Star79
ID: 24842847
Can you please be more specific.
Thanks.
0
 

Author Comment

by:Star79
ID: 24842950
I have given the correct drive name and also the odbc driver is installed too
0
Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24845410
This is an Oracle error, so you have the correct driver, but your client is not configured right. Verify your tnsnames.ora, sample below.

Use tnsping to see if the service works from Oracle without .NET

# Replace CAT with your database instance name
# Replace the ip address with your server's ip address
# Save to {ORACLE_HOME}/network/admin/tnsnames.ora
# Then verify with:  tnsping CAT
# And:  sqlplus scott/tiger@CAT            <-- change scott/tiger to a valid user/pass
CAT =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.5)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = CAT)
    )
  )

Open in new window

0
 
LVL 48

Expert Comment

by:schwertner
ID: 24846725
You have to pay attention to the following components:

1. Host name of Oracle server
2. Protocol used for connection
3. Port used
4. Service name of the Oracle instance

Set these parameters very carefully.

Additionaly ensure that there are not fiorewalls and antiviruses between.
Be aware that the port mentioned is used only to initiate connection.
After that it will be changed to other.
So the other port should not be blocked.
0
 

Author Comment

by:Star79
ID: 24849709
Iam able to connect to the DB through the tool SQL Developer..
Dont see a possibility of error in the tnsnames.ora file
0
 
LVL 48

Expert Comment

by:schwertner
ID: 24850168
SQLDeveloper doesn't use Oracle client and TNSNAMES.ORA file at all.
It uses jdbc connection.
Check ALL tnsnames.ora files for relevance.
0
 

Author Comment

by:Star79
ID: 24853635
checked all the tnsnames.ora files everything seems to be good...
Any inputs will help a lot..
Thanks
0
 
LVL 48

Expert Comment

by:schwertner
ID: 24853949
returning to the roots and to the message " The driver doesn't support the version of ODBC behavior that the application requested "
it seems ID:24842828Author:strickddDate:07/13/09 10:08 PM
is correct.
Possibly you have to use the Oracle driver (available on OTN) or to search on Microsoft site for further notes. Of course I can also do this, but I your experience will bring more.
0
 

Author Comment

by:Star79
ID: 24861990
Hello All,
Just an update on the error Iam getting currently.

ex      {"ORA-12154: TNS:could not resolve the connect identifier specified\n"}      System.Data.OracleClient.OracleException

The connection string used is MS ODBC for oracle and is below:
  <add key="connectionstring3" value="Password=GoldGold*1;User ID=AMDB;Data Source=AMDB_LOCAL;"/>


Any help appreciated a lot...
Thanks.
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24862099
I do not see that you ever tried tnsping <SERVICE> where service is the alias in your tnsnames.ora
0
 
LVL 48

Expert Comment

by:schwertner
ID: 24862295
I do not see the connection details

You have to pay attention to the following components:

1. Host name of Oracle server
2. Protocol used for connection
3. Port used
4. Service name of the Oracle instance

Set these parameters very carefully.

These seems not to be enough:

Server=Test;Uid=Test1;Pwd=Gold;"/>

0
 

Author Comment

by:Star79
ID: 24862317
I tried the tnsping and it returned back with 'service is running"
Thanks.
0
 
LVL 48

Expert Comment

by:schwertner
ID: 24862410
You do not provide the needed parameters for the connection.

Also issue on the server

lsnrctl services

to see the services
0
 

Author Comment

by:Star79
ID: 24870675
The below is the entry in my tnsnames.ora file against which Iam connecting:
AMDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Testserver)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = AMDB)
    )
  )
I tried the tnsping AMDB(if Iam correct) and it returned back with "failed to resolve name"
Thanks for any input....this has been eating my days !!!!
0
 
LVL 48

Expert Comment

by:schwertner
ID: 24870833
This means that you have more then one Oracle product on the machine.
Find ALL tnsnames.ora files and see which is the correct.
Also if you have Net MAnager (Oracle product in Oracle run )
see if the test on this entry is successful or not.
all firewalls - off. Antiviruses - off.
0
 

Accepted Solution

by:
Star79 earned 0 total points
ID: 24872023
Just an update...the issue resolved with changing the sqlnet file with the param
"EZCONNECT"
Thanks.
0

Featured Post

CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

Question has a verified solution.

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

A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Suggested Courses

801 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