September 17th, 2013, 11:05 AM
Connecting VB.Net to Oracle 11GR2 DB
I need to connect to an Orace 11GR2 database from a VB.Net Desktop application. I am getting various errors depending on what connection string I use.
Errors are either ORA 12154: TNS Name cannot be resolved or, Data Provider Internal Error (-3000) (error and string association in code snippet).
As a reference, I have followed the instructions from:
I have installed the most recent Oracle Client with ODAC, tested the connection with the SQL Developer utility and all seems good.
Any ideas on what to do next?
Using Visual Studio 2005 on an XP developers workstation.
Here is my function for connecting:
Function openOracle() As OracleConnection
Dim orconn As New OracleConnection
Dim cnstr As String
dbfail = False
' (DESCRIPTION =
' (ADDRESS_LIST =
' (ADDRESS = (PROTOCOL = TCP)(HOST = e9db)(PORT = 1521))
' (CONNECT_DATA =
' (SERVICE_NAME = orcl.domain.local)
cnstr = "Data Source=(DESCRIPTION =" & _
" (ADDRESS = " & _
" (PROTOCOL = TCP)(HOST = e9db)(PORT = 1521)" & _
" )" & _
" (CONNECT_DATA =" & _
" (SERVICE_NAME = orcl.domain.local)" & _
" );" & _
" User Id=un;" & _
" Password=pass" ' <-- ORA 12154
'cnstr = "Data Source=un/pass@e9db:1521/orcl;" ' <-- ORA 12154
'cnstr = "Data Source=ORCL;User ID=un;Password=pass" ' <-- Data Provider internal error (-3000)
orconn.ConnectionString = cnstr
Catch ex As OracleException
dbfail = True
Dim Message As String = "An error occurred while attempting to open the Oracle connection " & vbCrLf & "The error returned is: " & ex.Message.ToString()
Dim Caption As String = "Error Detected with Oracle Connection"
Dim Buttons As MessageBoxButtons = MessageBoxButtons.OK
MessageBox.Show(Message, Caption, Buttons)
Last edited by rick7423; September 19th, 2013 at 09:22 AM.
There are 10 types of people in the world, those that understand binary and those that don't.
Using VS 2010
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!