Question

Microsoft ODBC Driver ORA-12154 could not resolve service name from VB

Asked by: mjzalewski

I am making changes to a legacy VB 6 application. My VB code looks like this:

   Dim cn As New ADODB.Connection
   cn.CursorLocation = adUseClient
   cn.Open "DSN=MYDB"

I get the following error (although the code is working in the legacy production system)

   Run-time error '-2147467259 (80004005)':

   [Microsoft][ODBC driver for Oracle][Oracle]ORA-12154: TNS:could not
   resolve service name

My DSN entry (it's a System DSN, using the Microsoft ODBC Driver for Oracle) looks like this:

   Data Source Name: MYDB
   Description:      My Database
   User Name:        user/password
   Server:           DBD

My TNSNAMES.ORA file looks like this:

  DBD =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = mydb.mydomain.com)(PORT = 1521))
      )
      (CONNECT_DATA =
        (SID = DBD)
      )
    )

I am trying to run this using client version 8.1.7 on Windows 2000, and the database server has 8.1.6

I can do TNSPING DBD and it works fine.

I can connect to the database using SQL Plus without problems.

What could my problem be?

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2003-06-24 at 14:54:17ID20658873
Tags

odbc

,

oracle

,

driver

,

microsoft

Topic

Oracle 3rd Party Tools

Participating Experts
4
Points
400
Comments
17

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Ora-12154
    i'm trying to connect with Microsoft ODBD for oracle and keep receiving the ORA-12154 error - could not resolve service name. What am I missing?
  2. [Oracle][ODBC][Ora]Error while trying to retrieve te…
    I am trying to connect to an Oracle database and keep getting this error: [Oracle][ODBC][Ora]Error while trying to retrieve text for error ORA-12154. Can anyone help?
  3. ORA-12154: TNS could not resolve ervice name
    Hi I'm using Oracle 7.3.4 client and Oracle 7 Odbc driver. When i tried to connect to a remote database through sql plus 3.3, i was getting the ERROR: ORA-12154: TNS:could not resolve service name.. I added the service name in tnsnames.ora file also but still getting that ...
  4. [Oracle][ODBC][Ora]ORA-12154: TNS:coul…
    Hi I'm trying to connect to an oracle database using VBA code in EXCEL and it comes up with this error when I try to run the macro [Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve service name I think the setting might be wrong also just in case this helps Set cnOra = ...
  5. ORA-12154: TNS:could not resolve service name
    HI I AM TRYING TO CONNECT TO ORACLE DATABASE FROM AN ASP PAGE . I AM GETTING THE FOLLOWING ERROR Microsoft OLE DB Provider for ODBC Drivers error '80040e4d' [Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve service name /wi/login.asp, line 72 THE LINE 72 CODE IS ...
  6. ORA-12154: TNS:could not resolve service name
    I have a VB6 project. When I run it from with in the VB6 development enviornmnet the database connections works. However, when I compile the project, the same code gives the following set of errors when the EXE is ran. Error No: 00001 An error occurred while connecting to ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: anand_2000vPosted on 2003-06-25 at 09:26:44ID: 8798882

can u post the info about ur sqlnet.ora file

 

by: mjzalewskiPosted on 2003-06-25 at 16:54:52ID: 8801749

My SQLNET.ORA looks like this

  LOG_FILE_CLIENT = sqlnet.log
  AUTOMATIC_IPC = OFF
  NAMES.DIRECTORY_PATH = TNSNAMES
  SQLNET.AUTHENTICATION_SERVICES= (NTS)
  LOG_DIRECTORY_CLIENT = c:\Oracle\Ora81\logs
  SQLNET.CRYPTO_SEED = 4fhfguweotcadsfdsafjkdsfqp5f201p45mxskdlfdasf
  TNSPING.TRACE_LEVEL = 4

The mystery deepens because I have also tried the following:

1) In VB, do ChDir "C:\Oracle\Ora81\Network\Admin" (that's off my Oracle Home)
    cn.Open "DSN=MYDB"

Same problem

2) Change TNSNAMES.ORA to use a SERVICE_NAME instead of a SID

 DBD =
   (DESCRIPTION =
     (ADDRESS_LIST =
       (ADDRESS = (PROTOCOL = TCP)(HOST = mydb.mydomain.com)(PORT = 1521))
     )
     (CONNECT_DATA =
       (SERVICE_NAME = MYDB.mydomain.com)
     )
   )

Same problem. (It works either way through SQL*Plus or TNSPING)

3) Change the line in SQLNET.ORA

  SQLNET.AUTHENTICATION_SERVICES= (none)

Same Problem

4) In VB, change to a DSN-Less connection
   cn.Open "Provider=MSDASQL;DRIVER={Microsoft ODBC for ORACLE};UID=user;PWD=password;Server=DBD"

Same problem

5) Test the DSN using the Oracle ODBC Test Program.

Same problem

6) Create a DSN using the Oracle ODBC Driver

This works fine from both VB and the Oracle ODBC Test Program

 

by: anand_2000vPosted on 2003-06-25 at 18:26:03ID: 8802042

Make sure you are using the latest MDAC version which will give you the latest bug fixes for the Microsoft ODBC Driver.
In reality Oracle driver has not been licensed to Microsoft. So Microsoft Oracle OLEDB driver is a bridge from OLEDB client to Oracle DB Network lib. so you may have to install Network lib.

 

by: mjzalewskiPosted on 2003-06-26 at 10:45:40ID: 8807165

I don't think I need to install the Oracle Network lib. Not even sure what that is.

If it is NET80, that is obviously already installed (otherwise SQL*Plus would not work, neither would the Oracle ODBC driver).

I am using MDAC 2.6 (Build 6526). Will check if anything is newer. I begin to suspect that this may be the answer. Can't think of why else the Microsoft ODBC driver would fail when the Oracle ODBC driver works.

 

by: cdevxPosted on 2003-06-26 at 11:09:11ID: 8807324

I had this problem with an ASP application.  The MS ODBC would work and stop.  Frustrating.  If I remember correctly, I had to re-install MDAC every single F*(&% time
and then re-boot.  It Sucked.

I tried using Oracle ODBC, but I could not find any documenatation

I switched to Oracle's 0040.  VB COM component.  Don't know how much code you would have to re-write to switch.

You could try a 3rd party driver from someone like Merant.

 

by: portolanusPosted on 2003-06-30 at 11:55:38ID: 8829706

To mjzalewski...
A bit of an open door I guess: you mentioned the solution yourself: use the Oracle ODBC driver. You might be able to download it from OTN (http://otn.oracle.com/ or http://otn.oracle.com/software/tech/windows/odbc/content.html).
I've experienced the same problems. They were solved by using the Oracle ODBC Driver.
Should anyone comment on the fact that Microsoft's ODBC Driver for Oracle is better than Oracle's: it was!
Good luck and Regards,
Portolanus

 

by: ssaravanamoorthyPosted on 2003-07-08 at 02:14:25ID: 8875514

Hi,
You cannot use a higher version client to a lower version database server. Try with same version of oracle 8.1.6

Bye,
Moorthy.

 

by: mjzalewskiPosted on 2003-07-10 at 14:09:07ID: 8896755

ssaravanamoorthy

Actually, you cannot use a lower version client to connect to a higher version database. According to the documentation, 8.1.7 should be able to connect to anything above 7.2. Also, if that was correct, then why would the Oracle driver work and also SQL*Plus, TNSPING, etc.

I re-installed from Oracle 8.1.6, and still have the same problem. But the version mismatch might be on the right track. The error message changed however. Now, from Oracle ODBC Test, I get

  SQLSTATE: NA00
  Native Error Code:0
  Driver Message:[Microsoft][ODBC driver for Oracle] [Oracle]

Visual BASIC gives something very similar

  Run-time error '-2147467259 (80004005)':
  [Microsoft][ODBC driver for Oracle][Oracle]

(In other words, now it does not give 'ORA-12154 could not resolve service name' any more. Now the message from the ODBC driver is emtpy).

I use PVCS Dimensions, which requires Oracle 8.1.7, but is installed in a seperate ORA_HOME.

 

by: anand_2000vPosted on 2003-07-10 at 21:13:59ID: 8898798

Microsoft driver for Oracle does have a lot of  probelms!!! Can you try out the same with Oracle driver for Oracle? As you have already (Re)installed Oracle this driver would also be available.

 

by: mjzalewskiPosted on 2003-07-17 at 17:31:02ID: 8948207

My problem is not with the Oracle driver. It is with the Microsoft Driver.

Everything seems to work with the Oracle driver. But the software I am developing for must use the Microsoft Driver.

One more thing I found. In the Oracle ODBC Test program, there is a help option 'Making sure SQL*NET is OK'. I know SQL*NET is OK, because TNSPING and SQLPLUS work just fine. But the help screen says

1) The file ORAWIN95\ORAINST\win95.rgs or ORANT\ORAINST\nt.rgs should show "Sql*net" as being installed. If you don't see this, you need to install it from the \NT_X86 or \WIN32 or \WIN95 directory need to your CD roms, or if you can't find it, you may need to order it (ask for "Sqlnet for win 95" or "Sqlnet for win NT" ).

I do not have eitehr a win95.rgs or nt.rgs anywhere on the system. I *do* have a file named "Oracle 816 Production.rgs", but it has 0 bytes.

 

by: portolanusPosted on 2003-07-19 at 03:17:41ID: 8957663

Hai mjzalewski,

As I said before, and anand_2000v agreed (He's #10 expert at the moment, I am new here), there's a time to persist, and there's a time to let go.
Drop the Microsoft ODBC-driver and use the Oracle ODBC-driver.

I'm a bit puzzled: How come that "But the software I am developing for must use the Microsoft Driver"?
Do you use Developing software that refuses to connect through Oracle's ODBC-driver?
Do you have a manager who, not behindered by any specific technical knowledge ;-), has a strong personal oppinion?
Any other specific reason?

With curious regards,
Portolanus.

 

by: anand_2000vPosted on 2003-07-19 at 04:43:07ID: 8957800

I couldn't agree more with you Port, but still supposing "a manager who, not behindered by any specific technical knowledge ;-), has a strong personal oppinion?" is true we cannot blame the asker....:)
 to try out the Asker's angle once again, Oracle recomends that you get your latest MDAC upgrade(whatever that is- some Microsoft speak I'm sure). That might just solve your problem.

 

by: cdevxPosted on 2003-07-20 at 15:59:44ID: 8963735

When on path does not provide the answer, you must choose a different path.  Go with the Oracle Driver, you'll have to recode the app.  Put all the data access code in a class file or build a COM component (dll) to access the data through the app.

Then when this stuff happens you can port the app over quickly and painlessly if the SQL statements are pretty much the same.

I also have spoken with other Oracle users who switched from Microsofts ODBC to Oracles/a 3rd parties ODBC and avoided the problem you are having.  Each would get the driver to work but the problem would re-occur.  

I gave up after a week of the microsoft driver kept failing wiht oracle 8i.  Oracle driver and 0040 never failed.

 

by: mjzalewskiPosted on 2003-08-06 at 11:35:52ID: 9093566

Portolanus:

I am developing a piece to a working program. So the Microsoft driver works in the current version of production, but does not work on my system. Also, the Microsoft driver supports a curious feature -- the DBA can specify the production user and password in the DNS entry by entering 'user/password' from the ODBC Administration applet where the Microsoft ODBC for Oracle Setup window prompts for 'User Name'. You can't do the same from the Oracle driver. And there are other differences.

The system has been working in production (with the Microsoft driver) since 1999. I am changing only one piece, and cannot regression test the entire application.

If I were developing a new system, then yes, I could say 'Just install the Oracle ODBC driver, and we can deal with how to set the password through a .INI file or something'. But since the bulk of the system is in place and will not be changed, switching the driver is not an option.

I know the problem is difficult. That's why I gave it 400 points. An answer that says 'just use the Oracle driver' is not worth 400 points. I appreciate the suggestion (which has been offered by several of the responders), but in my case, it does not solve my particular problem.

In the meantime, I have completed most of the development, doing as much of the actual programming and unit testing as I could with the Oracle driver. The QA testers will use a test system, which has the Microsoft driver installed (the Microsoft driver works there, but my coding changes may not ...)

 

by: cdevxPosted on 2003-08-06 at 15:24:29ID: 9095279

I would email and try to get Microsoft and Oracle on the phone until they can resolve the issue.  I don't know how much time you have left on this project, or what the budget constraints are, but you are coming to crtical mass, and this is the last known issue (to you).

Try porting you code to the test system and see if that works.  Make sure you don't kill the legacy app, make backups of everything.  When I had this problem it was with an NT 4.0 machine.

Whatever is causing this must be deep inside.   I think the flow goes something like this...
App->ODBC32.dll->msorcl32.dll->SQL net->SQL-Net Listener->database.  
It fails somewhere between msorcl32.dll and SQL-net,  right, since SQL-net can connect?   I guess it could fail anywhere after SQL-net.

Hmm?  Search Tech Net.  Found this, you've probably seen it.  Anyway here it is:

The ODBC Driver for Oracle supports only SQL*Net 2.3 or later.

To enable this driver to work with your Oracle client software, the client's registry must be modified by running a registry file from a command line. Multiple instances of the client software should not run concurrently. These files are listed in the following table and are located within the same directory structure that contains your MDAC installation.

Windows 2000
mtxoci81x_win2k.reg (So, I guess they need you to run this file.)


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSDTC\MTxOCI]
"OracleXaLib"="oraclient8.dll"
"OracleSqlLib"="orasql8.dll"
"OracleOciLib"="oci.dll"

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/oledb/htm/oledboraprovider_7.asp

Found this, but I believe you tried this solution.  It never worked for me.
Caution   Installing Oracle software over the Microsoft Data Access Components (MDAC) may overwrite current versions of MDAC. If problems arise using ODBC components, reinstall MDAC.

Here is the link with some info.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/orcdrvsdk_5.asp

Good Luck, you can resolve this.

 

by: mjzalewskiPosted on 2003-08-07 at 12:04:04ID: 9102511

cdevx gets the bannana.

It was the registry entries described in

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/oledb/htm/oledboraprovider_7.asp

Mine were set up for Oracle 7.x on Windows NT. So if anyone else has this problem, it might be fruitful to check the registry as described in the anser from cdevx

 

by: cdevxPosted on 2003-08-07 at 19:11:20ID: 9105019

Cool!  Thanks

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...