Firebird ADO.NET Provider SDK Documentation - v1.7

FbCommandBuilder Class

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

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

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         FirebirdSql.Data.Firebird.FbCommandBuilder

[Visual Basic]
<DesignerCategory(Category:="Component")>
NotInheritable Public Class FbCommandBuilder
    Inherits Component
[C#]
[DesignerCategory(Category="Component")]
public sealed class FbCommandBuilder : Component

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

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

To generate INSERT, UPDATE, or DELETE statements, the FbCommandBuilder uses the SelectCommand property to retrieve a required set of metadata. If you change the value of SelectCommand after the metadata has been retrieved (for example, after the first update), you then should call the RefreshSchema method to update the metadata.

Example

public DataSet SelectRows(DataSet myDataSet,string myConnection,string mySelectQuery,string myTableName) 
{
    FbConnection  myConn     = new FbConnection(myConnection);    
    FbDataAdapter myDataAdapter = new FbDataAdapter();
    FbTransaction myTxn         = myConn.BeginTransaction();
    
    myDataAdapter.SelectCommand = new FbCommand(mySelectQuery, myConn, myTxn);
    FbCommandBuilder custCB     = new FbCommandBuilder(myDataAdapter);

    myConn.Open();

    DataSet custDS = new DataSet();
    myDataAdapter.Fill(custDS, "Employee");

    //code to modify data in dataset here

    //Without the FbCommandBuilder this line would fail
    myDataAdapter.Update(custDS, "Employee");

    myConn.Close();

    return custDS;
 }        
                

Requirements

Namespace: FirebirdSql.Data.Firebird

Assembly: FirebirdSql.Data.Firebird (in FirebirdSql.Data.Firebird.dll)

See Also

FbCommandBuilder Members | FirebirdSql.Data.Firebird Namespace