Data-Base
asked on
C# parses Oracle's tnsnames.ora into array?
Hello,
I found many solution and scripts on-line, but none worked will or was to armature!
I'm looking for a script where it takes the tnsnames.ora file and parse it into "array" or whatever
that I can easy use it with combo-box to show the names and when the user select the name the system le's say ping the IP or the host
I need the name,host,ports,SID,servic e, what ever I can get
cheers
I found many solution and scripts on-line, but none worked will or was to armature!
I'm looking for a script where it takes the tnsnames.ora file and parse it into "array" or whatever
that I can easy use it with combo-box to show the names and when the user select the name the system le's say ping the IP or the host
I need the name,host,ports,SID,servic
cheers
ASKER
thanks,
it look nice (I saw it before) but for some reason it stops round here
private ArrayList ParseText(string text)
{
ArrayList list = new ArrayList();
string pattern =
@"(?<name>[A-Z\-_]+\.WORLD )|" +
@"(PROTOCOL = (?<protocol>[A-Z]+))|" +
@"(HOST = (?<host>[A-Z0-9._]+))|" +
@"(PORT = (?<port>[0-9]+))|" +
@"(SID = (?<sid>[A-Za-z0-9.\-_]+))| " +
@"(SERVICE_NAME = (?<service>[A-Z\-._]+))";
TNSEntry entry = null;
foreach (Match m in Regex.Matches(text, pattern))
{
string name = m.Groups["name"].Value;
string protocol = m.Groups["protocol"].Value ;
string host = m.Groups["host"].Value;
string port = m.Groups["port"].Value;
string service = m.Groups["service"].Value;
string sid = m.Groups["sid"].Value;
not sure why
cheers
it look nice (I saw it before) but for some reason it stops round here
private ArrayList ParseText(string text)
{
ArrayList list = new ArrayList();
string pattern =
@"(?<name>[A-Z\-_]+\.WORLD
@"(PROTOCOL = (?<protocol>[A-Z]+))|" +
@"(HOST = (?<host>[A-Z0-9._]+))|" +
@"(PORT = (?<port>[0-9]+))|" +
@"(SID = (?<sid>[A-Za-z0-9.\-_]+))|
@"(SERVICE_NAME = (?<service>[A-Z\-._]+))";
TNSEntry entry = null;
foreach (Match m in Regex.Matches(text, pattern))
{
string name = m.Groups["name"].Value;
string protocol = m.Groups["protocol"].Value
string host = m.Groups["host"].Value;
string port = m.Groups["port"].Value;
string service = m.Groups["service"].Value;
string sid = m.Groups["sid"].Value;
not sure why
cheers
>but for some reason it stops round here
with error(s)? which one(s)?
with error(s)? which one(s)?
ASKER
the thing does not show any error, but it return nothing at all !!!!
I just added MessageBox.Show("Hello!") as a brake point and then I found out that the message box does not show in this area !!!!!
I just added MessageBox.Show("Hello!") as a brake point and then I found out that the message box does not show in this area !!!!!
ASKER
I think the problem is within the (regular expression), I redone it but using another method by analyzing the output of the tnsping :-)
I will work farther on other solutions :-)
cheers
I will work farther on other solutions :-)
cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What was the regular expression you came up with? I have the same issue.
https://www.experts-exchange.com/questions/21608389/How-to-parse-Oracle-TNSNAMES-ORA-file.html