dotConnect for Oracle Documentation
Devart.Data.Oracle Namespace / OracleHomeCollection Class
Members Example

In This Topic
    OracleHomeCollection Class
    In This Topic
    Represents a list of available Oracle homes.
    Syntax
    Remarks
    You can use this collection to get information about the Oracle homes installed at your system. To see all available Oracle homes, use the OracleConnection.Homes property of the static interface of the OracleConnection class. Use the DefaultHome property to retrieve the OracleHome object representing the system's default Oracle home. Use the Item(String) property to get the information about the Oracle home with the specified name.

    Note: This class is not used in the .NET Standard 1.3 compatible assembly.

    Example
    In this sample we retrieve the Oracle home which is default in the system. After that, we iterate through all available homes trying to connect to the "OraServer" Oracle server as Scott.
    // Get the complete collection of Oracle homes available in this system.
    OracleHomeCollection homes = OracleConnection.Homes;
    
                // Check the default Oracle home.
    OracleHome defaultHome = homes.DefaultHome;
    Console.WriteLine("The default Oracle home in this system is " + defaultHome.Name);
    
                // Create a connection.
    OracleConnection conn = new OracleConnection();
    conn.Server = "OraServer";
    conn.UserId = "Scott";
    conn.Password = "tiger";            
    
                // Try to connect to the "OraServer" Oracle server as Scott/tiger using each of Oracle homes available.
    Console.WriteLine("\nTrying to connect to server \"OraServer\" as Scott/tiger:\n");            
    foreach (OracleHome home in homes)
                {
                    conn.Home = home.Name;
                    try
                    {
                        conn.Open();
                        Console.WriteLine("Successfully connected using " + home.Name);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Failed trying to connect via " + home.Name + ": " + ex.Message);
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
    
    Console.ReadLine();
    ' Get the complete collection of Oracle homes available in this system.
    Dim homes As OracleHomeCollection = OracleConnection.Homes
    
    ' Check the default Oracle home.
    Dim defaultHome As OracleHome = homes.DefaultHome
    Console.WriteLine("The default Oracle home in this system is " + defaultHome.Name)
    
    ' Create a connection.
    Dim conn As OracleConnection = New OracleConnection()
    conn.Server = "OraServer"
    conn.UserId = "Scott"
    conn.Password = "tiger"
    
    ' Try to connect to the "OraServer" Oracle server as Scott/tiger using each of Oracle homes available.
    Console.WriteLine(vbCrLf + "Trying to connect to server ""OraServer"" as Scott/tiger:" + vbCrLf)
    
    For Each home In homes
    conn.Home = home.Name
        Try
    conn.Open()
    Console.WriteLine("Successfully connected using " + home.Name)
    Catch ex As Exception
    Console.WriteLine("Failed trying to connect via " + home.Name + ": " + ex.Message)
        Finally
    conn.Close()
        End Try
    Next
    
    Console.ReadLine()
    Inheritance Hierarchy

    System.Object
       Devart.Data.Oracle.OracleHomeCollection

    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also