Using a DataSet as the data source

In DataWindow Designer, you can specify ADO DataSet as the data source for a DataWindow object. The DataWindow wizard prompts you to specify the name of the XSD file that contains the DataSet, then you can select the DataTable you want to use and design the presentation of the DataWindow in the DataWindow painter.

For more information and a list of datatype mappings from the DataSet to the DataWindow, see the chapter on defining DataWindow objects in the DataWindow Designer User’s Guide.

At runtime, there are two ways to use a DataWindow with a DataSet:

The examples in this section use an XSD file that contains two DataAdapters: one for each of the department and employee tables from the EAS Demo DB (which are joined on the dept_id column). The columns used are the dept_id and dept_name columns from the department table, and the emp_id, emp_fname, emp_lname, salary, and dept_id columns from the employee table.

The following XSD file shows the typed DataSet generated from the DataAdapters for the department and employee tables:

<?xml version="1.0" standalone="yes"?>
<xs:schema id="DeptEmployee" targetNamespace="http://www.tempuri.org/DeptEmployee.xsd" xmlns:mstns="http://www.tempuri.org/DeptEmployee.xsd" xmlns="http://www.tempuri.org/DeptEmployee.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified">
  <xs:element name="DeptEmployee" msdata:IsDataSet="true">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element name="department">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="dept_id" type="xs:int" />
              <xs:element name="dept_name" type="xs:string" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="employee">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="emp_id" type="xs:int" />
              <xs:element name="emp_fname" type="xs:string" />
              <xs:element name="emp_lname" type="xs:string" />
              <xs:element name="dept_id" type="xs:int" />
              <xs:element name="salary" type="xs:decimal" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
    <xs:unique name="Constraint1" msdata:PrimaryKey="true">
      <xs:selector xpath=".//mstns:department" />
      <xs:field xpath="mstns:dept_id" />
    </xs:unique>
    <xs:unique name="employee_Constraint1" msdata:ConstraintName="Constraint1" msdata:PrimaryKey="true">
      <xs:selector xpath=".//mstns:employee" />
      <xs:field xpath="mstns:emp_id" />
    </xs:unique>
  </xs:element>
</xs:schema>