Link to home
Start Free TrialLog in
Avatar of Data-Base
Data-BaseFlag for Norway

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

cheers
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Avatar of Data-Base

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
>but for some reason it stops round here

with error(s)? which one(s)?
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 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
ASKER CERTIFIED SOLUTION
Avatar of Data-Base
Data-Base
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What was the regular expression you came up with? I have the same issue.