OracleCommandBuilder Class

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

Namespace: System.Data.OracleClient
Assembly: System.Data.OracleClient (in

Public NotInheritable Class OracleCommandBuilder
	Inherits DbCommandBuilder
Dim instance As OracleCommandBuilder

public final class OracleCommandBuilder extends DbCommandBuilder
public final class OracleCommandBuilder extends DbCommandBuilder
Not applicable.

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.

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]

Private Function SelectOracleRows(connection As String, queryString As String, tableName As String) As DataSet

   Dim connection As New OracleConnection(connection)
   Dim dataAdapter As New OracleDataAdapter()
   Dim dataSet As DataSet = New DataSet

   dataAdapter.SelectCommand = New OracleCommand(queryString, connection)

   Dim cmdBuilder As OracleCommandBuilder = New OracleCommandBuilder(dataAdapter)

   dataAdapter.Fill(dataSet, tableName)
      ' Code to modify data in DataSet here 
      ' Without the OracleCommandBuilder this line would fail.
   dataAdapter.Update(dataSet, tableName)
End Function


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 goes here...

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


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

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1