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

In This Topic
    OracleHome Class
    In This Topic
    Represents an Oracle home.
    Syntax
    'Declaration
     
    Public NotInheritable Class OracleHome 
    public sealed class OracleHome 
    Remarks

    Use the OracleHome properties to retrieve name, version, physical path and language settings (the NLS_LANG variable) for the specifed Oracle home. Use the GetClientInfo method to get the Oracle globalization settings of current Oracle home, such as date format, time zone, currency and language. Use the GetServerList method to see the list of Oracle servers (TNS names) available for the current Oracle home.

    OracleHome has no public constructors, it can only be retrieved from the OracleHomeCollection. The complete collection of all available Oracle homes can be get from the static interface of the OracleConnection class. See OracleHomeCollection and the OracleConnection.Homes property of the OracleConnection class.

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

    Example
    In this example we retrieve the globalization settings of the "OraClient" Oracle home; after that, we try to connect as Scott to all servers described in the tnsnames.ora file of OraClient.
    // Get the OracleHome instance corresponding to the "OraClient" Oracle home.
    OracleHome home = OracleConnection.Homes["OraClient"];
                
                // Print some globalization settings of the current home.
    OracleGlobalization glob = home.GetClientInfo();
    Console.WriteLine("The Oracle home is registered for: " + glob.Territory);
    Console.WriteLine("Character set is " + glob.ClientCharacterSet);
    Console.WriteLine("Time zone is " + glob.TimeZone);
    Console.WriteLine("Date format is " + glob.DateFormat);
    
                // Create a connection.
    OracleConnection conn = new OracleConnection();
    conn.UserId = "Scott";
    conn.Password = "tiger";
                
                // Try to connect to each server available for the current Oracle home.
                Console.WriteLine("\nTrying to connect as Scott/tiger:\n");
    string[] servers = home.GetServerList();
                foreach (string serverName in servers)
                {                
                    conn.Server = serverName;
                    try
                    {
                        conn.Open();
                        Console.WriteLine("Successfully connected to " + serverName);
                    }
                    catch(Exception ex)
                    {
                        Console.WriteLine("Failed connecting to " + serverName + ": " + ex.Message);
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
    
                Console.ReadLine();
    ' Get the OracleHome instance corresponding to the "OraClient" Oracle home.
    Dim home As OracleHome = OracleConnection.Homes.Item("OraClient")
    
    ' Print some globalization settings of the current home.
    Dim glob As OracleGlobalization = home.GetClientInfo()
    Console.WriteLine("The Oracle home is registered for: " + glob.Territory)
    Console.WriteLine("Character set is " + glob.ClientCharacterSet)
    Console.WriteLine("Time zone is " + glob.TimeZone)
    Console.WriteLine("Date format is " + glob.DateFormat)
    
    ' Create a connection.
    Dim conn As OracleConnection = New OracleConnection()
    conn.UserId = "Scott"
    conn.Password = "tiger"
    
    ' Try to connect to each server available for the current Oracle home.
    Console.WriteLine(vbCrLf + "Trying to connect as Scott/tiger:" + vbCrLf)
    Dim servers As Array = home.GetServerList()
    For Each serverName In servers
    conn.Server = serverName
        Try
    conn.Open()
    Console.WriteLine("Successfully connected to " + serverName)
    Catch ex As Exception
    Console.WriteLine("Failed connecting to " + serverName + ": " + ex.Message)
        Finally
    conn.Close()
        End Try
    Next
    
    Console.ReadLine()
    Inheritance Hierarchy

    System.Object
       Devart.Data.Oracle.OracleHome

    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