VB.NET connection to Oracle using System.Data.OracleClient.dll

Posted on 2004-08-25
Last Modified: 2008-01-09
I am trying to connect to an Oracle database but I keep getting the following error message:

ORA-12154: TNS:could not resolve service name
at System.Data.OracleClient.DBObjectPool.GetObject(Object owningObject, Boolean& isInTransaction) at System.Data.OracleClient.OracleConnectionPoolManager.GetPooledConnection(String encryptedConnectionString, OracleConnectionString options, OracleConnection owningObject, Boolean& isInTransaction) at System.Data.OracleClient.OracleConnection.OpenInternal(OracleConnectionString parsedConnectionString, Object transact) at System.Data.OracleClient.OracleConnection.Open() at EntMont.ls_test.BindData() in c:\inetpub\wwwroot\EntMont\ls_test.aspx.vb:line 51

I am running this on my local host.  
I can connect to the database using SQL+.
I have given the ASPNET user rights to the Ora81 directory which contains the subdirectories with the TNSNAMES.ORA.
I have added a reference in my project to the System.Data.OracleClient.
The connection string I am using contains the User ID, Data Source, and Password.

Any help would be greatly appreciated.

Question by:mattclip
  • 2

Expert Comment

ID: 11893246
mimic this:

dfwConn is my oracleclient connection

fill in the 3 spots

            strCn = "Data Source=DATABASE;User Id=USER;Password=PASS;Integrated Security=no;"
            dfwConn = New OracleConnection
            dfwConn.ConnectionString = strCn

Author Comment

ID: 11893599
Found my problem.  I was using the wrong value for the Data Source.  I am used to using SQL Server so I put the IP address in for the datasource, but with Oracle you need to put the TNS name that you used in the TNSNAMES.ORA file.  Note: TNS name must be 16 characters or less.

Expert Comment

ID: 11893689

Accepted Solution

DarthMod earned 0 total points
ID: 12143284
Submitted to PAQ with points refunded (500)

Community Support Moderator

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Converting C# Objects into JSON file 7 65
Change data in datatable 8 30
Protecting vb6 & .Net code Obfuscation 18 94
Getfiles in 28 42
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

19 Experts available now in Live!

Get 1:1 Help Now