Private _StrConn As String
Dim _Host As String = "192.000.0.000"
Dim _Port As String = "1521"
Dim _SID As String = "databaseName"
Dim _Username As String = "admin"
Dim _Password As String = "password"
'=========== DataBase Oracle ===============
Public ReadOnly Property ConnectionString() As String
Get
_StrConn = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & _Host & ")(PORT=" & _Port & ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" & _SID & ")));User Id=" & _Username & ";Password=" & _Password & ";"
Return _StrConn
End Get
End Property
Private _OrclConnection As OracleConnection
Public ReadOnly Property OrclConnection() As OracleConnection
Get
_OrclConnection = New OracleConnection(ConnectionString)
Return _OrclConnection
End Get
End Property
Public conn As OracleConnection
Public Function ConnectionOpen() As Boolean
Dim Y As Boolean = True
If conn Is Nothing Then
conn = New OracleConnection(ConnectionString)
End If
If conn.State = ConnectionState.Closed Then
Try
conn.Open()
Catch ex As Exception
MsgBox("Cannot open database connection")
Y = False
End Try
End If
Return Y
End Function
Public Sub ConnectionClose()
If conn IsNot Nothing Then
If conn.State <> ConnectionState.Closed Then
Try
conn.Close()
conn.Dispose()
Catch ex As Exception
End Try
End If
End If
conn = Nothing
End Sub