tnowacoski
asked on
Parsing tnsnames.ora for SID names in VB.net
I have been searching around and did not find an exact match to this question.
Using VB.NET 2005, what would be the best way to parce the SID names from the TNSNAMES.ORA file.
I am looking to enumerate this list into a ComboBox for Oracle Authenication.
I was looking at regex but am not sure.
Also, can I get an example?
Here is what I have: Visual Studio .NET 2005, Oracle 9I, Oracle Data Adaptor.
Using VB.NET 2005, what would be the best way to parce the SID names from the TNSNAMES.ORA file.
I am looking to enumerate this list into a ComboBox for Oracle Authenication.
I was looking at regex but am not sure.
Also, can I get an example?
Here is what I have: Visual Studio .NET 2005, Oracle 9I, Oracle Data Adaptor.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here's my attempt.
I'm not sure what permissions you would need to grant to read the tnsnames file from ORACLE_HOME so this example expects it to be in the current directory.
--------------------------
<%@ import namespace = "System" %>
<%@ import namespace = "System.IO" %>
<html>
<title>Regex Sample</title>
<body>
<script language="vb" runat="server">
sub page_load(sender as object, e as eventargs)
Dim FILENAME as String = Server.MapPath("tnsnames.o ra")
Dim objStreamReader as StreamReader
objStreamReader = File.OpenText(FILENAME)
Dim contents as String = objStreamReader.ReadToEnd( )
objStreamReader.Close()
Dim pat As String = "^\w*\s="
Dim r As New Regex(pat, RegexOptions.MultiLine)
Dim m As Match = r.Match(contents)
While m.Success
response.write("<BR>Match= " + replace(m.ToString()," =",""))
m = m.NextMatch()
End While
end sub
</script>
</form>
</body>
</html>
I'm not sure what permissions you would need to grant to read the tnsnames file from ORACLE_HOME so this example expects it to be in the current directory.
--------------------------
<%@ import namespace = "System" %>
<%@ import namespace = "System.IO" %>
<html>
<title>Regex Sample</title>
<body>
<script language="vb" runat="server">
sub page_load(sender as object, e as eventargs)
Dim FILENAME as String = Server.MapPath("tnsnames.o
Dim objStreamReader as StreamReader
objStreamReader = File.OpenText(FILENAME)
Dim contents as String = objStreamReader.ReadToEnd(
objStreamReader.Close()
Dim pat As String = "^\w*\s="
Dim r As New Regex(pat, RegexOptions.MultiLine)
Dim m As Match = r.Match(contents)
While m.Success
response.write("<BR>Match=
m = m.NextMatch()
End While
end sub
</script>
</form>
</body>
</html>
ASKER