Previous Topic

Next Topic

How Values Are Changed

Changed values are held in the DataGridView row that is bound to the DataSet returned from the query.

Each data row maintains a version of its changes after it is edited, but before the AcceptChanges method is called.

The DataSet values are used as parameters in the update query and each parameter is associated with the respective column.

The values from the previous version of the row are used as the parameters to the WHERE clause. Using the DataSet, the update can be run.

public void RouteChange(DataSet dataSet)

{

    try

    {

        ingresDataAdapter5.UpdateCommand.Parameters.Clear();

        ingresDataAdapter5.UpdateCommand.Parameters.Add("@rt_airline",

            Ingres.Client.IngresType.NChar, "rt_airline");

        ingresDataAdapter5.UpdateCommand.Parameters.Add("@rt_flight_num",

            Ingres.Client.IngresType.Int, "rt_flight_num");

        ingresDataAdapter5.UpdateCommand.Parameters.Add("@rt_depart_from",

            Ingres.Client.IngresType.NChar, "rt_depart_from");

        ingresDataAdapter5.UpdateCommand.Parameters.Add("@rt_arrive_to",

            Ingres.Client.IngresType.NChar, "rt_arrive_to");

        ingresDataAdapter5.UpdateCommand.Parameters.Add("@rt_depart_at",

            Ingres.Client.IngresType.DateTime, "rt_depart_at");

        ingresDataAdapter5.UpdateCommand.Parameters.Add("@rt_arrive_at",

            Ingres.Client.IngresType.DateTime, "rt_arrive_at");

        ingresDataAdapter5.UpdateCommand.Parameters.Add(

            "@rt_arrive_offset",

            Ingres.Client.IngresType.TinyInt, "rt_arrive_offset");

        ingresDataAdapter5.UpdateCommand.Parameters.Add("@rt_flight_day",

            Ingres.Client.IngresType.NChar, "rt_flight_day");

        ingresDataAdapter5.UpdateCommand.Parameters.Add(

            "@airline",

            IngresType.NChar, "rt_airline").SourceVersion =

             DataRowVersion.Original;

        ingresDataAdapter5.UpdateCommand.Parameters.Add(

            "@flight",

            IngresType.Int, "rt_flight_num").SourceVersion =

            DataRowVersion.Original;

        ingresDataAdapter5.UpdateCommand.Parameters.Add(

            "@days",

            IngresType.NChar, "rt_flight_day").SourceVersion =

             DataRowVersion.Original;

        ingresDataAdapter5.Update(dataSet);

    }

    catch (IngresException ex)

    {

        DialogResult result = DisplayError(ex);

        throw;

    }

}


© 2006 Ingres Corporation. All rights reserved.