OracleDataSourceEnumerator Class

An OracleDataSourceEnumerator object allows applications to generically obtain a collection of data sources to connect to.

Supported Only in ADO.NET 2.0-Compliant ODP.NET

Class Inheritance

System.Object

  System.DbDataSourceEnumerator

    Oracle.DataAccess.Client.OracleDataSourceEnumerator

Declaration

// C#
public sealed class OracleDataSourceEnumerator : DbDataSourceEnumerator

Thread Safety

All public static methods are thread-safe, although instance methods do not guarantee thread safety.

Example

// C#
 
using System;
using System.Data;
using System.Data.Common;
using Oracle.DataAccess.Client;
 
class DataSourceEnumSample
{
  static void Main()
  {
    string ProviderName = "Oracle.DataAccess.Client";
 
    DbProviderFactory factory = DbProviderFactories.GetFactory(ProviderName);
 
    if (factory.CanCreateDataSourceEnumerator)
    {
      DbDataSourceEnumerator dsenum = factory.CreateDataSourceEnumerator();
      DataTable dt = dsenum.GetDataSources();
 
      // Print the first column/row entry in the DataTable
      Console.WriteLine(dt.Columns[0] + " : " + dt.Rows[0][0]);
      Console.WriteLine(dt.Columns[1] + " : " + dt.Rows[0][1]);
      Console.WriteLine(dt.Columns[2] + " : " + dt.Rows[0][2]);
      Console.WriteLine(dt.Columns[3] + " : " + dt.Rows[0][3]);
      Console.WriteLine(dt.Columns[4] + " : " + dt.Rows[0][4]);
    }
    else
      Console.Write("Data source enumeration is not supported by provider");
  }
}

Requirements

Namespace: Oracle.DataAccess.Client

Assembly: Oracle.DataAccess.dll

ODP.NET Version: ODP.NET for .NET Framework 2.0 or ODP.NET for .NET Framework 4


OracleDataSourceEnumerator Members

OracleDataSourceEnumerator members are listed in the following tables.

OracleDataSourceEnumerator Public Methods

OracleDataSourceEnumerator Public Methods are listed in Table 7-10.

Table 7-10 OracleDataSourceEnumerator Method

Method Description

GetDataSources

Returns a DataTable object with information on all the TNS alias entries in the tnsnames.ora file



OracleDataSourceEnumerator Public Methods

The OracleDataSourceEnumerator static method is listed in Table 7-11.

Table 7-11 OracleDataSourceEnumerator Method

Method Description

GetDataSources

Returns a DataTable object with information on all the TNS alias entries in the tnsnames.ora file


GetDataSources

This method returns a DataTable object with information on all the TNS alias entries in the tnsnames.ora file.

Declaration

// C#
public override DataTable GetDataSources();
 

Return Value

A DataTable object.

Remarks

This method returns a DataTable object for each TNS Alias entry that exists in the tnsnames.ora file.

If the tnsnames.ora file is not found, then the returned DataTable object is empty.

The following columns are returned for each row, but only the InstanceName column is populated.

  • InstanceName (type: System.String)

  • ServerName (type: System.String)

  • ServiceName (type: System.String)

  • Protocol (type: System.String)

  • Port (type: System.String)