Solved

Get error when accessing Oracle DB from VB program

Posted on 2002-07-25
9
162 Views
Last Modified: 2010-05-02

1)  I installed Oracle 8.0 on a server.

2)  I tested connectivity to a databse through the Oracle tools. I made a connection. The DB name is EPA1.

3) I have a VB program which accesses the same databse. When running the program I get the following message:

"TNS could not resolve service name"  
How can I connect via Oracle but not using VB?

Is it a driver issue?  Please help.



0
Comment
Question by:FidelMike
9 Comments
 
LVL 3

Accepted Solution

by:
PNJ earned 100 total points
ID: 7177238
Have you set up the service (Eg MyService) using "Net8 Easy Config"? Then you connect along the lines of (Eg using ADO):

   Set gadoConnect = New ADODB.Connection
   gadoConnect.ConnectionString = "Extended Properties=""" & _
   "Driver=MyService;" & _
   "UID=USERNAME;PWD=PASSWORD;" & _
   "ConnectString=MyService;"""
   gadoConnect.ConnectionTimeout = 30
   gadoConnect.CursorLocation = adUseServer
   gadoConnect.Open , , , adConnectUnspecified
0
 
LVL 3

Expert Comment

by:PNJ
ID: 7177241
Have you set up the service (Eg MyService) using "Net8 Easy Config"? Then you connect along the lines of (Eg using ADO):

   Set gadoConnect = New ADODB.Connection
   gadoConnect.ConnectionString = "Extended Properties=""" & _
   "Driver=MyService;" & _
   "UID=USERNAME;PWD=PASSWORD;" & _
   "ConnectString=MyService;"""
   gadoConnect.ConnectionTimeout = 30
   gadoConnect.CursorLocation = adUseServer
   gadoConnect.Open , , , adConnectUnspecified
0
 
LVL 3

Expert Comment

by:PNJ
ID: 7177245
damn it. Double-clicked "Submit" - sorry.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 2

Expert Comment

by:damienm
ID: 7177311
You should have a file called Tnsnames.ora inside c:\orant\net80\admin, the data source you supplied in VB should be inside this file if not it will give this error.
0
 
LVL 3

Expert Comment

by:PNJ
ID: 7177315
...isn't that what "Easy Config" does for you? :-)
0
 
LVL 3

Expert Comment

by:Elmo_
ID: 7177550
FidelMike,

If you are not expierenced with messing with the tnsnames.ora stick with PNJ's solution.  You can run into numerous problems if you mess with the file.

Net 8 Easy config is you best bet.

Ed.
0
 

Expert Comment

by:paulll
ID: 7180762
I assume Oracle client is installed for the client PC for the Oracle version you need to access.

If an Oracle database is not set up with Oracle client install, search your orant/network/admin directory for "tnsnames.ora" (path may vary)

You need an entry such as:
EPA1 =
 (DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = server.orabox.com)(PORT = 1521))
   )
   (CONNECT_DATA =
     (SERVICE_NAME = EPA1)
   )
 )

DESCRIPTION, ADDRESS_LIST and CONNECT_DATA do not need to be filled in.

Where "EPA1" is the server name.
server.orabox.com is the address refecting the IP address, you must know the address.
1521 is the PORT, you must know the port.



Private ConDB As ADODB.Connection
Private ProviderType, User As String, UserPassword As String

ProviderType = "Provider=OraOLEDB.Oracle" & User & UserPassword & ";Data Source=EPA1;DistribTx=0"
ConDB.Open ProviderType

Make sure you have rights to the database for the user & password.

Paul
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8040626
Hi FidelMike,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept PNJ's comment(s) as an answer.

FidelMike, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8095669
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 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