C# parses Oracle's tnsnames.ora into array?


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,service, what ever I can get

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
Data-BaseAuthor Commented:

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

Guy Hengel [angelIII / a3]Billing EngineerCommented:
>but for some reason it stops round here

with error(s)? which one(s)?
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Data-BaseAuthor Commented:
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 !!!!!
Data-BaseAuthor Commented:
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 :-)

Data-BaseAuthor Commented:
I solved the issue, I needed to re write the regular expressions :-)

Thank you all

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.