Export (0) Print
Expand All

DbDataAdapter.UpdateCommand Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets a command used to update records in the data source.

Namespace: System.Data.Common
Assembly: System.Data (in system.data.dll)

public DbCommand UpdateCommand { get; set; 
/** @property */
public DbCommand get_UpdateCommand ()

/** @property */
public void set_UpdateCommand (DbCommand value)

public function get UpdateCommand () : DbCommand

public function set UpdateCommand (value : DbCommand)

Property Value

A IDbCommand used during Update to update records in the data source for modified rows in the data set.

During Update, if this property is not set and primary key information is present in the DataSet, the UpdateCommand will be automatically generated.

The following example creates the derived class OleDbDataAdapter and sets some of its properties.

public static OleDbDataAdapter CreateCustomerAdapter(OleDbConnection conn)
{
  OleDbDataAdapter da = new OleDbDataAdapter();
  OleDbCommand cmd;
  OleDbParameter parm;

  // Create the SelectCommand.

  cmd = new OleDbCommand("SELECT * FROM Customers " +
                       "WHERE Country = @Country AND City = @City", conn);

  cmd.Parameters.Add("@Country", OleDbType.VarChar, 15);
  cmd.Parameters.Add("@City", OleDbType.VarChar, 15);

  da.SelectCommand = cmd;

  // Create the UpdateCommand.

  cmd = new OleDbCommand("UPDATE Customers SET CustomerID = @CustomerID, CompanyName = @CompanyName " +
                       "WHERE CustomerID = @oldCustomerID", conn);

  cmd.Parameters.Add("@CustomerID", OleDbType.Char, 5, "CustomerID");
  cmd.Parameters.Add("@CompanyName", OleDbType.VarChar, 40, "CompanyName");

  parm = cmd.Parameters.Add("@oldCustomerID", OleDbType.Char, 5, "CustomerID");
  parm.SourceVersion = DataRowVersion.Original;

  da.UpdateCommand = cmd;

  return da;


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft