Data Binding 3 : Data Binding « Database ADO.net « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Database ADO.net » Data BindingScreenshots 
Data Binding 3

/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury, 
   Zach Greenvoss, Shripad Kulkarni, Neil Whitlow

Publisher: Peer Information
ISBN: 1861007663
*/

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace DataBinding_3
{
    /// <summary>
    /// Summary description for DataBinding_3.
    /// </summary>
    public class DataBinding_3 : System.Windows.Forms.Form
    {
        private System.Windows.Forms.DataGrid grdOrders;
        private System.Windows.Forms.DataGrid grdOrderDetails;
        private System.Windows.Forms.DataGrid grdCustomers;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public DataBinding_3()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            SqlConnection cn=new SqlConnection(@"data source=(local);uid=sa;password=;database=northwind");
      
            DataSet ds = new DataSet("CustOrders");

            SqlDataAdapter daCust=new SqlDataAdapter("select * from customers;select * from orders;select * from [order details]",cn);
            daCust.Fill(ds);
      
            ds.Relations.Add("CustOrder",ds.Tables["Table"].Columns["customerid"],ds.Tables["Table1"].Columns["customerid"]);
            ds.Relations.Add("OrderDetail",ds.Tables["Table1"].Columns["orderid"],ds.Tables["Table2"].Columns["orderid"]);

            grdCustomers.DataSource=ds;
            grdCustomers.DataMember="Table";
            grdOrders.DataSource=ds;
            grdOrders.DataMember="Table.CustOrder";
            grdOrderDetails.DataSource=ds;
            grdOrderDetails.DataMember="Table.CustOrder.OrderDetail";
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Disposebool disposing )
        {
            ifdisposing )
            {
                if (components != null
                {
                    components.Dispose();
                }
            }
            base.Disposedisposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.grdCustomers = new System.Windows.Forms.DataGrid();
            this.grdOrders = new System.Windows.Forms.DataGrid();
            this.grdOrderDetails = new System.Windows.Forms.DataGrid();
            ((System.ComponentModel.ISupportInitialize)(this.grdCustomers)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.grdOrders)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.grdOrderDetails)).BeginInit();
            this.SuspendLayout();
            // 
            // grdCustomers
            // 
            this.grdCustomers.AllowNavigation = false;
            this.grdCustomers.DataMember = "";
            this.grdCustomers.HeaderForeColor = System.Drawing.SystemColors.ControlText;
            this.grdCustomers.Location = new System.Drawing.Point(4016);
            this.grdCustomers.Name = "grdCustomers";
            this.grdCustomers.Size = new System.Drawing.Size(448152);
            this.grdCustomers.TabIndex = 0;
            // 
            // grdOrders
            // 
            this.grdOrders.AllowNavigation = false;
            this.grdOrders.DataMember = "";
            this.grdOrders.HeaderForeColor = System.Drawing.SystemColors.ControlText;
            this.grdOrders.Location = new System.Drawing.Point(40176);
            this.grdOrders.Name = "grdOrders";
            this.grdOrders.Size = new System.Drawing.Size(448144);
            this.grdOrders.TabIndex = 1;
            // 
            // grdOrderDetails
            // 
            this.grdOrderDetails.DataMember = "";
            this.grdOrderDetails.HeaderForeColor = System.Drawing.SystemColors.ControlText;
            this.grdOrderDetails.Location = new System.Drawing.Point(40328);
            this.grdOrderDetails.Name = "grdOrderDetails";
            this.grdOrderDetails.Size = new System.Drawing.Size(448136);
            this.grdOrderDetails.TabIndex = 2;
            // 
            // DataBinding_3
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(513);
            this.ClientSize = new System.Drawing.Size(528483);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                  this.grdOrderDetails,
                                                                  this.grdOrders,
                                                                  this.grdCustomers});
            this.Name = "DataBinding_3";
            this.Text = "DataBinding_3";
            ((System.ComponentModel.ISupportInitialize)(this.grdCustomers)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.grdOrders)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.grdOrderDetails)).EndInit();
            this.ResumeLayout(false);

        }
        #endregion

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() 
        {
            Application.Run(new DataBinding_3());
        }
    }
}

           
       
Related examples in the same category
1.ADO.NET Binding: Handling ErrorsADO.NET Binding: Handling Errors
2.ADO.NET Binding: Master DetailADO.NET Binding: Master Detail
3.ADO.NET Binding : Multiple Control BindingADO.NET Binding : Multiple Control Binding
4.ADO.NET Binding : UnsynchronizedADO.NET Binding : Unsynchronized
5.Data Binding 4
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.