Share via


Removing a row

To remove a row from a table, first read the row with the Change() method. This retrieves the row and locks it. Then use the Remove() statement to remove the row from the table.

The following C# example reads and locks the row for the inventory item "WIRE100" in the IV_Item_MSTR table. If the item is successfully read, it is removed from the table.

// Variable for any table operation error
TableError err;

// Create a reference to the table
IvItemMstrTable ItemMasterTable;
ItemMasterTable = Dynamics.Tables.IvItemMstr;

// Set the key to use for the table
// Key 1 - Contains the Item Number
ItemMasterTable.Key = 1;

// Set the key field in the table
ItemMasterTable.ItemNumber.Value = "WIRE100";

// Attempt to read the row. The Change() method will lock the row.
err = ItemMasterTable.Change();

if (err == TableError.NoError)
{
    // Attempt to remove the row
    err = ItemMasterTable.Remove();

    if (err != TableError.NoError)
    {
        MessageBox.Show("An error occured removing the row: " +
        err.ToString());
    }
}

// Close the table
ItemMasterTable.Close();