1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
Private Function GetOracleHome() As String
Dim rgkLM As RegistryKey = Registry.LocalMachine
Dim rgkAllHome As RegistryKey = rgkLM.OpenSubKey("SOFTWARE\ORACLE\ALL_HOMES")
MsgBox(rgkAllHome)
MsgBox("la")
If Not rgkAllHome.Equals("") Then
Dim strLastHome = ""
Dim objLastHome As Object = rgkAllHome.GetValue("LAST_HOME")
strLastHome = objLastHome.ToString()
Dim rgkActualHome As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\ORACLE\HOME" + strLastHome)
Dim strOraHome As String = ""
Dim objOraHome As Object = rgkActualHome.GetValue("ORACLE_HOME")
strOraHome = objOraHome.ToString()
strOracleHome = strOraHome
Return strOraHome
Else
MsgBox(rgkAllHome)
Return ""
End If
End Function
Private Function GetTNSNAMESORAFilePath() As String
If Not Me.GetOracleHome.Equals("") Then
strTNSNAMESORAFilePath = strOracleHome + "\NETWORK\ADMIN\TNSNAMES.ORA"
If Not (System.IO.File.Exists(strTNSNAMESORAFilePath)) Then
strTNSNAMESORAFilePath = strOracleHome + "\NET80\ADMIN\TNSNAMES.ORA"
Return strTNSNAMESORAFilePath
Else
Return strTNSNAMESORAFilePath
End If
Else
Return ""
End If
End Function
Public Function LoadTNSNames() As Collection
Dim DBNamesCollection As New Collection
Dim RegExPattern As String = "[\n][\s]*[^\(][a-zA-Z0-9_.]+[\s]*=[\s]*\("
GetTNSNAMESORAFilePath()
'Adicionando una línea en blanco a la collection
DBNamesCollection.Add("")
If Not strTNSNAMESORAFilePath.Equals("") Then
Try
'//check out that file does physically exists
Dim fiTNS As New System.IO.FileInfo(strTNSNAMESORAFilePath)
If (fiTNS.Exists) Then
If (fiTNS.Length > 0) Then
'//read tnsnames.ora file
Dim iCount As Integer
Try
For iCount = 0 To Regex.Matches(My.Computer.FileSystem.ReadAllText(fiTNS.FullName), RegExPattern).Count - 1
DBNamesCollection.Add(Regex.Matches(My.Computer.FileSystem.ReadAllText(fiTNS.FullName), RegExPattern).Item(iCount).Value.Trim.Substring(0, Regex.Matches(My.Computer.FileSystem.ReadAllText(fiTNS.FullName), RegExPattern).Item(iCount).Value.Trim.IndexOf(" ")))
Next
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End If
End If
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End If
Return DBNamesCollection
End Function |
Partager