?
Solved

Get error when accessing Oracle DB from VB program

Posted on 2002-07-25
9
Medium Priority
?
177 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 400 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

807 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