Solved

Problem Connecting to Oracle from .NET3.5 application

Posted on 2009-07-13
18
1,657 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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 …
Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

770 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