DbDataAdapter.UpdateCommand Propiedad
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Obtiene o establece un comando que se utiliza para actualizar registros en el origen de datos.
public:
property System::Data::Common::DbCommand ^ UpdateCommand { System::Data::Common::DbCommand ^ get(); void set(System::Data::Common::DbCommand ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Data.Common.DbCommand? UpdateCommand { get; set; }
[System.ComponentModel.Browsable(false)]
public System.Data.Common.DbCommand UpdateCommand { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.UpdateCommand : System.Data.Common.DbCommand with get, set
Public Property UpdateCommand As DbCommand
Interfaz IDbCommand utilizada mientras opera Update(DataSet) para actualizar registros del origen de datos para filas modificadas en el conjunto de datos.
- Atributos
En el ejemplo siguiente se crea la clase OleDbDataAdapter derivada y se establecen algunas de sus propiedades.
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;
}
Public Shared Function CreateCustomerAdapter(conn As OleDbConnection) As OleDbDataAdapter
Dim da As New OleDbDataAdapter()
Dim cmd As OleDbCommand
Dim parm As OleDbParameter
' 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
End Function
Durante Update, si esta propiedad no está establecida y la información de la clave principal está presente en DataSet, UpdateCommand se generará automáticamente .
Producto | Versiones |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
Comentarios de .NET
.NET es un proyecto de código abierto. Selecciona un vínculo para proporcionar comentarios: