
'Declaration Public NotInheritable Class TdCommandBuilder Inherits System.Data.Common.DbCommandBuilder Implements System.ComponentModel.IComponent, System.IDisposable
'Usage Dim instance As TdCommandBuilder
public sealed class TdCommandBuilder : System.Data.Common.DbCommandBuilder, System.ComponentModel.IComponent, System.IDisposable
public ref class TdCommandBuilder sealed : public System.Data.Common.DbCommandBuilder, System.ComponentModel.IComponent, System.IDisposable
TdCommandBuilder can generate DML (UPDATE, DELETE and INSERT) statements for a single table SELECT statement. TdCommandBuilder uses the SelectCommand property of the associated TdDataAdapter to retrieve column information. Later, column information is used to generate UPDATE, DELETE or INSERT statements. The target-row for an UPDATE or a DELETE statement is identified by The WHERE clause.
If it is included in the SELECT statement, the TdCommandBuilder will use the primary key column(s) to uniquely identify the target-row for an UPDATE or a DELETE statement. Otherwise, all columns returned by the SELECT statement are added to the WHERE clause
TdCommandBuilder will register as a listener for RowUpdating events generated by the associated TdDataAdapter (TdCommandBuilder.DataAdapter property). TdCommandBuilder will generate a new DML statement and set the TdRowUpdatingEventArgs. Command property. DML statements are generated based on the columns that are changed (UPDATE) in an updated row or columns that are inserted (INSERT) into a brand new row (TdRowUpdatingEventArgs.Row). Therefore, UPDATE and INSERT statements are generated for each RowUpdating event while the DELETE statement is static until the next call to TdCommandBuilder.RefreshSchema method.
You should call TdCommandBuilder.RefreshSchema if the SelectCommand property of the associated TdDataAdapter (TdCommandBuilder.DataAdapter property) has changed. RefreshSchema method updates the column information used to generate UPDATE, DELETE and INSERT statements in addition to updating the TdConnection and TdTransaction used for the Update.
public void DisplayUpdateCustomersTable(String connectionString, String commandText) { TdConnection cn = new TdConnection(connectionString); try { // Open a connection to Teradata cn.Open(); // Create a new adapter. TdDataAdapter adapter = new TdAdapter(commandText, cn); // Create a new command builder to generate DML statements. TdCommandBuilder cmdBuilder = new TdCommandBuilder(adapter); // Cache the results in a dataset DataSet ds = new DataSet(); adapter.fill(ds, “Call_Log”); // Display the table to user using DataGrid or other interfaces // Finally apply the changes back to the Teradata // Note that TdDataAdapter.UpdateCommand, InsertCommand and // DeleteCommand is generated by TdCommandBuilder. adapter.Update(ds, “Call_Log”); } finally { cn.Close(); } }
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Data.Common.DbCommandBuilder
Teradata.Client.Provider.TdCommandBuilder
Product | Versions | Platforms |
---|---|---|
.NET | 2.1, 3.1, 6 | Windows, Linux, MacOS |
.NET Framework | 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 | Windows |
.NET Standard | 2.0 | Windows, Linux, MacOS |