OracleHomeCollection Class
Represents a list of available Oracle homes.
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()
System.Object
Devart.Data.Oracle.OracleHomeCollection
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