The retrieve and update model

The retrieve and update model allows the DataWindow to work in the traditional manner. Data is retrieved from the underlying DataTable and can be manipulated (sorted, filtered, updated) as is done with a SQL data source.

The DataSet and DataTable must still be populated outside the DataWindow using a DataAdapter and the Fill method. The Retrieve method has a new overloaded version that copies data into the DataWindow.

After the data is retrieved from the DataTable, the DataWindow is “disconnected” from the DataTable and modifications are not applied to the table until the DataWindow UpdateData method is called. The same type of optimistic concurrency as is used with SQL data sources is used when modifications are applied to the DataTable.

Inserting, deleting, sorting, filtering, copying, moving, and the use of ShareData are all supported.

Example: Retrieve/Update model

This example creates two OLE DB data adapters using SQL queries that are the same as the SQL statements for a DataWindow object and a drop-down DataWindow and uses them to fill two DataSets. Then it retrieves data from the DataTables into a DataWindowControl and a DataWindowChild.

[C#]
OleDbDataAdapter daDept;
DataSet dsDept = new DataSet;
OleDbDataAdapter daDDDW;
DataSet dsDDDW = new DataSet;
String sqlStmt,sqlDDDW;
Sybase.DataWindow.DataWindowChild dwc;


// Specify a SQL query that is the same as the 
// DataWindow object's SQL statement
SqlStmt = "select dept_id, dept_name, dept_head_id from department";


// Specify a SQL query that is the same as the 
// drop-down DataWindow's SQL statement
SqlDDDW = "select emp_id from employee";


// Create the data adapters
daDept = new OleDbDataAdapter(sqlStmt,OleDbConn);
daDDDW = new OleDbDataAdapter(sqlDDDW, OleDbConn);

// Fill the DataSets
daDept.Fill(dsDept, "department");
daDDDW.Fill(dsDDDW, "employee");


// Get the DDDW 
dwc = dw_1.GetChild("dept_head_id");


// Retrieve data into the DDDW
dwc.Retrieve(dsDDDW.Tables("employee"));


// Retrieve data into the DataWindowControl
dw_1.Retrieve(dsDept.Tables("department"));