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.
// 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()
System.Object
Devart.Data.Oracle.OracleHome
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