To delete data from a table:
| Methods | Description |
Delete(<TableCodeName>Row row) |
Deletes the specified object from the table. |
Delete(string whereSql) |
Deletes records that match the specified criteria. |
DeleteAll |
Deletes all records from the table. |
DeleteBy<ForeignKeyColumnName> |
Deletes records from the table using the specified foreign key value. |
DeleteByPrimaryKey |
Deletes a record from the table using the specified primary key value. |
For example:
using(MyDatabase db = new MyDatabase())
{
// Delete a row from the User table using
the primary key values.
db.UserCollection.DeleteByPrimaryKey("John", "Smith");
// You do not need to close the DB
connection manually.
// The using statement does it automatically.
}
MyDatabase db = new MyDatabase();
try
{
// Delete a row from the User table using
the primary key values.
db.UserCollection.DeleteByPrimaryKey("John", "Smith");
}
finally
{
// Do not forget to close the DB connection
db.Close();
}
Dim db As New MyDatabase()
Try
' Delete a row from the User table
using the primary key values.
db.UserCollection.DeleteByPrimaryKey("John", "Smith")
Finally
' Do not forget to close the DB connection
db.Close()
End Try