Updating Data

To update data in a table:

Methods Description
Update(<TableCodeName>Row row) Updates a record in the table.
Update(System.Data.DataTable table) Updates the table.

For example:

[C#]

using(MyDatabase db = new MyDatabase())
{
    // Get a row from the User table using the primary key values
    UserRow user = db.UserCollection.GetByPrimaryKey("John", "Smith");

    // Change some of the row properties
    user.City = "Dallas";

    // Update data in the User table
    db.UserCollection.Update(user);

    // You do not need to close the DB connection manually.
    // The using statement does it automatically.

}

or

MyDatabase db = new MyDatabase();
try
{
    // Get a row from the User table using the primary key values
    UserRow user = db.UserCollection.GetByPrimaryKey("John", "Smith");

    // Change some of the row properties
    user.City = "Dallas";

    // Update data in the User table
    db.UserCollection.Update(user);
}
finally
{
    // Do not forget to close the DB connection
    db.Close();
}

[VB.NET]

Dim db As New MyDatabase()
Try
    ' Get a row from the User table using the primary key values
    Dim user As UserRow = db.UserCollection.GetByPrimaryKey("John", "Smith")

    ' Change some of the row properties
    user.City = "Dallas"

    ' Update data in the User table
    db.UserCollection.Update(user)
Finally
    ' Do not forget to close the DB connection
    db.Close()
End Try