Previous Topic

Next Topic

How You Add or Change Table Values Using the DataGridView

The result table returned by executing a search can be used for adding and changing values in the Route table using the editing capabilities of the DataGridView control.

Note: This example uses the ingresInsertCommand5, which was created when the ingresDataAdapter5 was added.

The event handler for detecting changes in the DataGridView control is routeBindingSource_PositionChanged. In the event handler, the row DataGridView row property is used to determine whether a value in an existing row was changed or added and to invoke the appropriate UPDATE or INSERT command.

The queries used are as follows.

INSERT

INSERT into route

    ( rt_id, rt_airline, rt_flight_num, rt_depart_from, rt_arrive_to,

        rt_depart_at, rt_arrive_at, rt_arrive_offset, rt_flight_day )

VALUES ( NEXT VALUE FOR rt_id, ?, ?, ?, ?, ?, ?, ?, ? )

UPDATE

UPDATE route

    SET rt_airline = ?, rt_flight_num = ?, rt_depart_from = ?,

        rt_arrive_to = ?, rt_depart_at = ?, rt_arrive_at = ?,

        rt_arrive_offset = ?, rt_flight_day = ?

 WHERE rt_airline = ? AND rt_flight_num = ? AND rt_flight_day = ?

You can write these queries using the Query Designer for the IngresCommand by changing the CommandText property, or assign them directly to the IngresCommand CommandText property as a string.

The table updateRoute is added to the RouteDataSet.

More information:

How You Add a Table for Updating the Route Table


© 2006 Ingres Corporation. All rights reserved.