Gets or sets a SQL statement or stored procedure used to delete records from the data set.
Namespace:
MySql.Data.MySqlClient
Assembly:
MySql.Data (in MySql.Data.dll) Version: 6.2.2.0
Syntax
Remarks
Examples
The following example creates a
MySqlDataAdapter and sets the
SelectCommand and DeleteCommand properties. It assumes you have already
created a
MySqlConnection object.
CopyVB.NET
Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter
Dim da As MySqlDataAdapter = New MySqlDataAdapter()
Dim cmd As MySqlCommand
Dim parm As MySqlParameter
cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn)
cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15)
cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15)
da.SelectCommand = cmd
cmd = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn)
parm = cmd.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id")
parm.SourceVersion = DataRowVersion.Original
da.DeleteCommand = cmd
Return da
End Function
CopyC#
public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn)
{
MySqlDataAdapter da = new MySqlDataAdapter();
MySqlCommand cmd;
MySqlParameter parm;
cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn);
cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15);
cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15);
da.SelectCommand = cmd;
cmd = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn);
parm = cmd.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id");
parm.SourceVersion = DataRowVersion.Original;
da.DeleteCommand = cmd;
return da;
}
See Also