Solved

Problem Connecting to Oracle from .NET3.5 application

Posted on 2009-07-13
18
1,641 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
  • 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
 
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 47

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 47

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 47

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 47

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 47

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 47

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
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…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
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…

758 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

22 Experts available now in Live!

Get 1:1 Help Now