Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle & VB
"News" <Contact_404_at_hotmail.com> wrote in message news:1141205288.082036.105510_at_e56g2000cwe.googlegroups.com...
Frank Weber a écrit :
> If you have Oracle 9 or 10 fully installed, there are some VB examples
> coming with. You just have to find them.
I have found many useful things in <ORACLE_HOME>\oo4o\VB\SAMPLES but not what I'm looking for ... :(
If I understand what you are requesting, I may be able to help. I think you want a list of available server names that is obtained from the TNSNames.ora file.
Public Function PopulateListBoxFromOracleTNSNames(ByRef lst As ListBox) As Boolean
On Error GoTo ERROR_HANDLER
Dim oReg As cRegistry
Dim strTNSNamesPath As String
Dim strBuffer As String Dim lngFileNum As Long Dim bytChar As Byte
Set oReg = New cRegistry
oReg.Root = HkeyLocalMachine
oReg.Key = "Software\Oracle"
strTNSNamesPath = oReg.GetValue("ORACLE_HOME") & "\network\ADMIN\tnsnames.ora"
lngFileNum = FreeFile
Open strTNSNamesPath For Input As lngFileNum
lst.Clear
Do Until EOF(lngFileNum)
Line Input #lngFileNum, strBuffer
strBuffer = RTrim(strBuffer)
If Len(strBuffer) > 0 Then bytChar = Asc(Left$(strBuffer, 1)) If IsCharAlpha(bytChar) Then lst.AddItem Trim$(Left$(strBuffer, InStr(1, strBuffer, "=") - 1)) End If End If
Close #lngFileNum
PopulateListBoxFromOracleTNSNames = CBool(lst.ListCount)
EXIT_HANDLER:
' Place Procedure Clean-up Code Here
Exit Function
ERROR_HANDLER:
' Place Error Handler Here
Resume EXIT_HANDLER
End Function
This is a brute force approach that seems to work with any of the TNSNames.ora files I have tried. It is part of a Query Builder application that I wrote that will connect to any database (Access, MSSQL, Oracle, ODBC). When connecting to oracle, it reads the TNSNames.ora file amd presents a list of available oracle instances to connect to.
I hope this is what you are after. If not, can you be more specific as to what you are trying to accomplish?
-- Al ReidReceived on Wed Mar 01 2006 - 06:52:20 CST
![]() |
![]() |