Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » ADO.NET » Downloads
 
Add your own
alternative version

ADO.NET for the Object-Oriented Programmer – Part One

, 19 Jan 2006 CPOL
This article will show how to accomplish these goals—use ADO.NET as a thin data transport layer, while still taking advantage of the data-binding capabilities of .NET user interface controls. As it turns out, it’s pretty easy.
namespace AdoNetDemo
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #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.buttonFlatSelect = new System.Windows.Forms.Button();
            this.buttonHierarchicalSelect = new System.Windows.Forms.Button();
            this.buttonInsert = new System.Windows.Forms.Button();
            this.buttonUpdate = new System.Windows.Forms.Button();
            this.buttonDelete = new System.Windows.Forms.Button();
            this.textBoxResults = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.buttonUndo = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // buttonFlatSelect
            // 
            this.buttonFlatSelect.Location = new System.Drawing.Point(12, 12);
            this.buttonFlatSelect.Name = "buttonFlatSelect";
            this.buttonFlatSelect.Size = new System.Drawing.Size(147, 23);
            this.buttonFlatSelect.TabIndex = 0;
            this.buttonFlatSelect.Text = "Flat \'Select\' Query";
            this.buttonFlatSelect.UseVisualStyleBackColor = true;
            this.buttonFlatSelect.Click += new System.EventHandler(this.buttonFlatSelect_Click);
            // 
            // buttonHierarchicalSelect
            // 
            this.buttonHierarchicalSelect.Location = new System.Drawing.Point(12, 41);
            this.buttonHierarchicalSelect.Name = "buttonHierarchicalSelect";
            this.buttonHierarchicalSelect.Size = new System.Drawing.Size(147, 23);
            this.buttonHierarchicalSelect.TabIndex = 1;
            this.buttonHierarchicalSelect.Text = "Hierarchical \'Select\' Query";
            this.buttonHierarchicalSelect.UseVisualStyleBackColor = true;
            this.buttonHierarchicalSelect.Click += new System.EventHandler(this.buttonHierarchicalSelect_Click);
            // 
            // buttonInsert
            // 
            this.buttonInsert.Location = new System.Drawing.Point(165, 12);
            this.buttonInsert.Name = "buttonInsert";
            this.buttonInsert.Size = new System.Drawing.Size(147, 23);
            this.buttonInsert.TabIndex = 2;
            this.buttonInsert.Text = "\'Insert\' Query";
            this.buttonInsert.UseVisualStyleBackColor = true;
            this.buttonInsert.Click += new System.EventHandler(this.buttonInsert_Click);
            // 
            // buttonUpdate
            // 
            this.buttonUpdate.Location = new System.Drawing.Point(318, 12);
            this.buttonUpdate.Name = "buttonUpdate";
            this.buttonUpdate.Size = new System.Drawing.Size(147, 23);
            this.buttonUpdate.TabIndex = 3;
            this.buttonUpdate.Text = "\'Update\' Query";
            this.buttonUpdate.UseVisualStyleBackColor = true;
            this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
            // 
            // buttonDelete
            // 
            this.buttonDelete.Location = new System.Drawing.Point(165, 41);
            this.buttonDelete.Name = "buttonDelete";
            this.buttonDelete.Size = new System.Drawing.Size(147, 23);
            this.buttonDelete.TabIndex = 4;
            this.buttonDelete.Text = "\'Delete\' Query";
            this.buttonDelete.UseVisualStyleBackColor = true;
            this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
            // 
            // textBoxResults
            // 
            this.textBoxResults.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.textBoxResults.Location = new System.Drawing.Point(12, 92);
            this.textBoxResults.Multiline = true;
            this.textBoxResults.Name = "textBoxResults";
            this.textBoxResults.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
            this.textBoxResults.Size = new System.Drawing.Size(453, 263);
            this.textBoxResults.TabIndex = 5;
            // 
            // label1
            // 
            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.label1.BackColor = System.Drawing.SystemColors.ActiveCaption;
            this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
            this.label1.Location = new System.Drawing.Point(12, 76);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(453, 16);
            this.label1.TabIndex = 6;
            this.label1.Text = "Results";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // buttonUndo
            // 
            this.buttonUndo.Location = new System.Drawing.Point(318, 41);
            this.buttonUndo.Name = "buttonUndo";
            this.buttonUndo.Size = new System.Drawing.Size(147, 23);
            this.buttonUndo.TabIndex = 7;
            this.buttonUndo.Text = "Undo Update";
            this.buttonUndo.UseVisualStyleBackColor = true;
            this.buttonUndo.Click += new System.EventHandler(this.buttonUndo_Click);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(477, 367);
            this.Controls.Add(this.buttonUndo);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.textBoxResults);
            this.Controls.Add(this.buttonDelete);
            this.Controls.Add(this.buttonUpdate);
            this.Controls.Add(this.buttonInsert);
            this.Controls.Add(this.buttonHierarchicalSelect);
            this.Controls.Add(this.buttonFlatSelect);
            this.Name = "Form1";
            this.Text = "ADO.NET Demo";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button buttonFlatSelect;
        private System.Windows.Forms.Button buttonHierarchicalSelect;
        private System.Windows.Forms.Button buttonInsert;
        private System.Windows.Forms.Button buttonUpdate;
        private System.Windows.Forms.Button buttonDelete;
        private System.Windows.Forms.TextBox textBoxResults;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button buttonUndo;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

David Veeneman
Software Developer (Senior) Foresight Systems
United States United States
David Veeneman is a financial planner and software developer. He is the author of "The Fortune in Your Future" (McGraw-Hill 1998). His company, Foresight Systems, develops planning and financial software.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411023.1 | Last Updated 19 Jan 2006
Article Copyright 2006 by David Veeneman
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid