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

C# / C Sharp
1. 2D Graphics
2. Collections Data Structure
3. Components
4. Database ADO.net
5. Development Class
6. Event
7. File Stream
8. GUI Windows Form
9. Language Basics
10. Network
11. Office
12. Regular Expressions
13. Services Event
14. Thread
15. Web Services
16. Windows
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
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
w___w_w_.j_a___v__a___2_s___.___c__om_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.