1 Replies - 2829 Views - Last Post: 02 September 2012 - 11:00 AM

#1 nighttrain  Icon User is offline

  • D.I.C Regular

Reputation: 6
  • View blog
  • Posts: 325
  • Joined: 22-September 10

Problem with connection to database

Posted 16 May 2012 - 12:21 PM

Hello all,

I am comming here to you with issue that makes me crazy. Ok to point. I am developing windows application which is connecting to oracle database, then i retreive the data to excel. I got problem with connection to oracle database, sometimes its connecting and sometimes just not it's lottery. I doing all from this article from oracle site: http://www.oracle.co...s08-088541.html .

My code looks like this: (for test connection)

Dim oradb As String = "Data Source =" _
+ "(DESCRIPTION =" _
+ "(ADDRESS = (PROTOCOL = TCP)(HOST = 179.45.23.11)(PORT = 1521))" _
+ "(ADDRESS = (PROTOCOL = TCP)(HOST = 179.45.23.16)(PORT = 1521))" _
+ "(LOAD_BALANCE = yes)" _
+ "(CONNECT_DATA =" _
+ "(SERVER = DEDICATED)" _
+ "(SERVICE_NAME = act.ge.mert.com)" _
+ ")" _
+ ");User Id=login;Password=password;"

Dim conn As New OracleConnection(oradb) ' VB.NET

Try
conn.ConnectionString = oradb

conn.Open() ' VB.NET

If conn.State = ConnectionState.Closed Then
MsgBox("Not Connected to Oracle.")
Else
MsgBox("Success! You have been connected to oracle")
End If

Catch ex As OracleException
'MsgBox(ex.ToString())
Finally
' Close Connection
conn.Close()
End Try


The Error which i retreiving says:

onlyfortestoracle
Oracle.DataAccess.Client.OracleException ORA-12545: Connect failed because target host or object does not exist

at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)

at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)

at Oracle.DataAccess.Client.OracleConnection.Open()



The TNS which i take from oracle administrator is:
act.ge.mert.com =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 179.45.23.11)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 179.45.23.16)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = act.ge.mert.com)
)
)

act1.ge.mert.com =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 179.45.23.11)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = act.ge.mert.com)
(INSTANCE_NAME = act1)
)
)

act2.ge.mert.com =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 179.45.23.16)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = act.ge.mert.com)
(INSTANCE_NAME = act2)
)
)


I don't know mayby in oradb string i should change something? Please of help.

This post has been edited by nighttrain: 17 May 2012 - 04:37 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Problem with connection to database

#2 fuzz_collective  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 02-August 12

Re: Problem with connection to database

Posted 02 September 2012 - 11:00 AM

why not use the OracleConnectionStringBuilder class rather than hard coding the entire tns entry?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1