../E23174-03.epub /> ../E23174-03.mobi />

OracleClientFactory Class

An OracleClientFactory object allows applications to instantiate ODP.NET classes in a generic way.

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

Class Inheritance

System.Object

  System.Data.Common.DbProviderFactory

    Oracle.DataAccess.Client.OracleClientFactory

Declaration

// C#
public sealed class OracleClientFactory : DbProviderFactory

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 FactorySample
{
  static void Main()
  {
    string constr = "user id=scott;password=tiger;data source=oracle";
 
    DbProviderFactory factory =
            DbProviderFactories.GetFactory("Oracle.DataAccess.Client");
 
    DbConnection conn = factory.CreateConnection();
 
    try
    {
      conn.ConnectionString = constr;
      conn.Open();
 
      DbCommand cmd = factory.CreateCommand();
      cmd.Connection = conn;
      cmd.CommandText = "select * from emp";
 
      DbDataReader reader = cmd.ExecuteReader();
      while (reader.Read())
        Console.WriteLine(reader["EMPNO"] + " : " + reader["ENAME"]);
    }
    catch (Exception ex)
    {
      Console.WriteLine(ex.Message);
      Console.WriteLine(ex.StackTrace);
    }
  }
}

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


OracleClientFactory Members

OracleClientFactory members are listed in the following tables.

OracleClientFactory Public Properties

The OracleClientFactory public properties are listed in Table 7-1.

Table 7-1 OracleClientFactory Public Properties

Property Description

CanCreateDataSourceEnumerator

Indicates whether or not the CreateDataSourceEnumerator method is supported


OracleClientFactory Public Methods

OracleClientFactory Public Methods are listed in Table 7-2.

Table 7-2 OracleClientFactory Public Method

Method Description

CreateCommand

Returns a DbCommand object that represents an OracleCommand object

CreateCommandBuilder

Returns a DbCommandBuilder object that represents an OracleCommandBuilder object

CreateConnection

Returns a DbConnection object that represents an OracleConnection object

CreateConnectionStringBuilder

Returns a DbConnectionStringBuilder object that represents an OracleConnectionStringBuilder object

CreateDataAdapter

Returns a DbDataAdapter object that represents an OracleDataAdapter object

CreateDataSourceEnumerator

Returns a DbDataSourceEnumerator object that represents an OracleDataSourceEnumerator object

CreateParameter

Returns a DbParameter object that represents an OracleParameter object

CreatePermission

Returns a CodeAccessPermission object that represents an OraclePermission object



OracleClientFactory Public Properties

The OracleClientFactory public properties are listed in Table 7-3.

Table 7-3 OracleClientFactory Public Properties

Property Description

CanCreateDataSourceEnumerator

Indicates whether or not the CreateDataSourceEnumerator method is supported


CanCreateDataSourceEnumerator

This property indicates whether or not the CreateDataSourceEnumerator method is supported.

Declaration

// C#
public override bool CanCreateDataSourceEnumerator { get; }
 

Property Value

Returns true.

Remarks

ODP.NET supports the OracleDataSourceEnumerator object.


OracleClientFactory Public Methods

The OracleClientFactory public method is listed in Table 7-4.

Table 7-4 OracleClientFactory Public Method

Method Description

CreateCommand

Returns a DbCommand object that represents an OracleCommand object

CreateCommandBuilder

Returns a DbCommandBuilder object that represents an OracleCommandBuilder object

CreateConnection

Returns a DbConnection object that represents an OracleConnection object

CreateConnectionStringBuilder

Returns a DbConnectionStringBuilder object that represents an OracleConnectionStringBuilder object

CreateDataAdapter

Returns a DbDataAdapter object that represents an OracleDataAdapter object

CreateDataSourceEnumerator

Returns a DbDataSourceEnumerator object that represents an OracleDataSourceEnumerator object

CreateParameter

Returns a DbParameter object that represents an OracleParameter object

CreatePermission

Returns a CodeAccessPermission object that represents an OraclePermission object


CreateCommand

This method returns a DbCommand object that represents an OracleCommand object.

Declaration

// C#
public override DbCommand CreateCommand();

Return Value

A DbCommand object that represents an OracleCommand object.

CreateCommandBuilder

This method returns a DbCommandBuilder object that represents an OracleCommandBuilder object.

Declaration

// C#
public override DbCommandBuilder CreateCommandBuilder();
 

Return Value

A DbCommandBuilder object that represents an OracleCommandBuilder object.

CreateConnection

This method returns a DbConnection object that represents an OracleConnection object.

Declaration

// C#
public override DbConnection CreateConnection();
 

Return Value

A DbConnection object that represents an OracleConnection object.

CreateConnectionStringBuilder

This method returns a DbConnectionStringBuilder object that represents an OracleConnectionStringBuilder object.

Declaration

// C#
public override DbConnectionStringBuilder CreateConnectionStringBuilder();
 

Return Value

A DbConnectionStringBuilder object that represents an OracleConnectionStringBuilder object.

CreateDataAdapter

This method returns a DbDataAdapter object that represents an OracleDataAdapter object.

Declaration

// C#
public override DbDataAdapter CreateDataAdapter();
 

Return Value

A DbDataAdapter object that represents an OracleDataAdapter object.

CreateDataSourceEnumerator

This method returns a DbDataSourceEnumerator object that represents an OracleDataSourceEnumerator object.

Declaration

// C#
public override DbDataSourceEnumerator CreateDataSourceEnumerator();
 

Return Value

A DbDataSourceEnumerator object that represents an OracleDataSourceEnumerator object.

CreateParameter

This method returns a DbParameter object that represents an OracleParameter object.

Declaration

// C#
public override DbParameter CreateParameter();
 

Return Value

A DbParameter object that represents an OracleParameter object.

CreatePermission

This method returns a CodeAccessPermission object that represents an OraclePermission object.

Declaration

// C#
public override System.Security.CodeAccessPermission CreatePermission(
  System.Security.Permissions.PermissionState state);

Parameter

  • state

    A PermissionState object.

Return Value

A CodeAccessPermission object that represents an OraclePermission object.

Remarks

This method enables users, writing provider-independent code, to get a CodeAccessPermission instance that represents an OraclePermission object.