This documentation is archived and is not being maintained.

OracleCommandBuilder Class

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated database. This class cannot be inherited.

For a list of all members of this type, see OracleCommandBuilder Members.


[Visual Basic]
NotInheritable Public Class OracleCommandBuilder
   Inherits Component
public sealed class OracleCommandBuilder : Component
public __gc __sealed class OracleCommandBuilder : public Component
public class OracleCommandBuilder extends Component

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


The OracleDataAdapter does not automatically generate the SQL statements required to reconcile changes made to a DataSet associated with the database. However, you can create an OracleCommandBuilder object that generates SQL statements for single-table updates by setting the SelectCommand property of the OracleDataAdapter. Then, the OracleCommandBuilder generates any additional SQL statements that you do not set.

The relationship between an OracleDataAdapter and its corresponding OracleCommandBuilder is always one-to-one. To create this correspondence, you set the OracleDataAdapter property of the OracleCommandBuilder object. This causes the OracleCommandBuilder to register itself as a listener, which produces the output of RowUpdating events that affect the DataSet.

To generate INSERT, UPDATE, or DELETE statements, the OracleCommandBuilder uses the SelectCommand property to retrieve a required set of metadata.

The OracleCommandBuilder also uses the Connection, and Transaction properties referenced by the SelectCommand.

If you call Dispose, the OracleCommandBuilder is disassociated from the OracleDataAdapter, and the generated commands are no longer used.


[Visual Basic, C#, C++] The following example uses OracleCommand, along with OracleDataAdapter and OracleConnection, to select rows from a database. The example is passed an initialized DataSet, a connection string, a query string that is an SQL SELECT statement, and a string that is the name of the database table. The example then creates an OracleCommandBuilder.

[Visual Basic] 
Public Shared Function SelectOracleSrvRows(myConnection As String, mySelectQuery As String, myTableName As String) As DataSet
    Dim myConn As New OracleConnection(myConnection)
    Dim myDataAdapter As New OracleDataAdapter()
    myDataAdapter.SelectCommand = New OracleCommand(mySelectQuery, myConn)
    Dim cb As OracleCommandBuilder = New OracleCommandBuilder(myDataAdapter)


    Dim ds As DataSet = New DataSet
    myDataAdapter.Fill(ds, myTableName)

    ' Code to modify data in DataSet here 

    ' Without the OracleCommandBuilder this line would fail.
    myDataAdapter.Update(ds, myTableName)

End Function 'SelectOracleSrvRows

public static DataSet SelectOracleSrvRows(string myConnection, string mySelectQuery, string myTableName)
   OracleConnection myConn = new OracleConnection(myConnection);
   OracleDataAdapter myDataAdapter = new OracleDataAdapter();
   myDataAdapter.SelectCommand = new OracleCommand(mySelectQuery, myConn);
   OracleCommandBuilder cb = new OracleCommandBuilder(myDataAdapter);


   DataSet ds = new DataSet();
   myDataAdapter.Fill(ds, myTableName);

   //code to modify data in DataSet here

   //Without the OracleCommandBuilder this line would fail
   myDataAdapter.Update(ds, myTableName);


   return ds;

 static DataSet* SelectOracleSrvRows(String* myConnection, String* mySelectQuery, String* myTableName)
    OracleConnection* myConn = new OracleConnection(myConnection);
    OracleDataAdapter* myDataAdapter = new OracleDataAdapter();
    myDataAdapter->SelectCommand = new OracleCommand(mySelectQuery, myConn);
    OracleCommandBuilder* cb = new OracleCommandBuilder(myDataAdapter);


    DataSet* ds = new DataSet();
    myDataAdapter->Fill(ds, myTableName);

    //code to modify data in DataSet here

    //Without the OracleCommandBuilder this line would fail
    myDataAdapter->Update(ds, myTableName);


    return ds;

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Data.OracleClient

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Data.Oracleclient (in System.Data.Oracleclient.dll)

See Also

OracleCommandBuilder Members | System.Data.OracleClient Namespace