| Devart.Data.Oracle Namespace : OracleHomeCollection Class |
Represents a list of available Oracle homes.
For a list of all members of this type, see OracleHomeCollection members.
Devart.Data.Oracle.OracleHomeCollection
[Visual Basic]
Public Class OracleHomeCollection
Inherits CollectionBase
Implements ICollection , IEnumerable , IList [C#]
public class OracleHomeCollection : CollectionBase , ICollection , IEnumerable , IList 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 property to get the information about the Oracle home with the specified name.
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.
[C#]
// 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(); [Visual Basic]
' 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()OracleHomeCollection Members | Devart.Data.Oracle Namespace
© 2002 - 2013 Devart. All Rights Reserved.