Ejemplo n.º 1
0
        // build data set
        void Form1_Load(object sender, System.EventArgs e)
        {
            // create hierarchical DataSet
            DataSet ds   = new DataSet("Hierarchical DataSet");
            string  conn = GetConnectionString();

            // load tables
            string           sql = "select * from customers";
            OleDbDataAdapter da  = new OleDbDataAdapter(sql, conn);

            da.Fill(ds, "Customers");

            sql = "select * from orders";
            da  = new OleDbDataAdapter(sql, conn);
            da.Fill(ds, "Orders");

            sql = "select * from [order details]";
            da  = new OleDbDataAdapter(sql, conn);
            da.Fill(ds, "Details");

            // create relations
            ds.Relations.Add("CustomerOrders", ds.Tables["Customers"].Columns["CustomerID"], ds.Tables["Orders"].Columns["CustomerID"]);
            ds.Relations.Add("OrderDetails", ds.Tables["Orders"].Columns["OrderID"], ds.Tables["Details"].Columns["OrderID"]);

            // bind data set to grids
            _flexCustomers.SetDataBinding(ds, "Customers");
            _flexOrders.SetDataBinding(ds, "Customers.CustomerOrders");
            _flexDetails.SetDataBinding(ds, "Customers.CustomerOrders.OrderDetails");
        }
Ejemplo n.º 2
0
        void Form1_Load(object sender, System.EventArgs e)
        {
            // build connection string
            string conn = GetConnectionString();

            // fill two tables
            OleDbDataAdapter da = new OleDbDataAdapter("select * from products", conn);

            da.Fill(_ds, "Products");
            da = new OleDbDataAdapter("select * from categories", conn);
            da.Fill(_ds, "Categories");

            // create a relation
            _ds.Relations.Add("CategoriesProducts",
                              _ds.Tables["Categories"].Columns["CategoryID"],
                              _ds.Tables["Products"].Columns["CategoryID"]);

            // bind master/detail grids
            _flex1.Cols[0].Width = _flex2.Cols[0].Width = 20;
            _flex1.SetDataBinding(_ds, "Categories");
            _flex2.SetDataBinding(_ds, "Categories.CategoriesProducts");
        }