Friday, 12 April 2013

Moving towards connectivity

     Pretty much every application deals with data in some manner, whether the data comes from memory, databases, XML files, or something else. The location where we store the data can be called as Data Source or Data Store where a Data Source can be a file, database or indexing servers etc. Programming languages cannot communicate with Data Sources directly because each Data Source adopts a different protocol (set of rules) for communication, so to overcome the problem long back Microsoft has introduced intermediate technologies like JET, Odbc and Oledb which works like a bridge between the applications and Data Sources to communicate with each other.
     The Microsoft jet database engine is a database engine on which several microsoft products have been built. A database engine is the underlying component of a database, a collection of information stored on a computer in a systematic way. The first version of jet was developed in 1992, consisting of three modules which could be used to manipulate a database. Jet stands for Joint Engine Technology, sometimes been referred to as Microsoft jet engine or simply jet. Microsoft Access and Excel use JET as their underlying database engine.
    ODBC(Open Database Connectivity) is a standard C programming language middleware API for accessing database management systems (DBMS). ODBC accomplishes DBMS independence by using an OBBC driver as a translation layer between the application and the DBMS. An application uses ODBC functions through an ODBC driver manager with which it is linked, and the driver passes the query to the DBMS.
   OLE DB (Object Linking and embedded database), an API designed by Microsoft, allows accessing data from a variety of sources in a uniform manner. The API provides a set of interfaces implemented using the Compnent Object Model (COM). Microsoft originally intended OLE DB as a higher level replacement for, and successor to ODBC, extending its feature set to support a wider variety of non-relational databases such as object databases and spreadsheets that do not necessarily implement SQL.

Thursday, 11 April 2013

Introduction to ADO.NET

ADO.NET is a set of computer software components that programmers can use to access data and data services. It is a part of the base class library that is included with the Microsoft .Net Framework. It is commonly used by programmers to access and modify data stored in relational database systems, though it can also access data in non-relational database systems, though it can also access data in non-relational sources. ADO.NET is a set of classes that are organized in a number of namespaces. These namespaces provide developers access to databases to retrieve and update data. The classes of ADO.NET provide us with the means to access databases and execute T-SQL code that retrieves, inserts, updates and deletes data.

ADO.NET Data Architecture
  • Dataset : The dataset is a disconnected, in- memory representation of data. It can be considered as a local copy of the relevant portions f the database. The DataSet is persisted in memory and the data in it can be manipulated and updated independent of the database.

  • Data Provider: The Data Provider is responsible for providing and maintaining the connection to the database. A DataProvider is a set of related components that work  together to provide data in an efficient and performance driven manner. The .NET Framework currently comes wit two DataProviders: the SQL Data Provider which is designed only to work with Microsoft's SQL Server 7.0 or later and the OleDb DataProvider which allows us to connect to other types of databases like Access and Oracle.

Started learning ADO.net

     As I have just completed with Console applications and Windows applications I have started practicing ADO.net from today. 
     ADO.net is a set of classes that expose data access services to the .net programmer. ADO.net provides consistent access to data sources such as Microsoft SQL server, as well as data sources exposed through OLE DB and XML.
     ADO.net provides libraries for Data Source communication under the following namespaces
  • System.Data
  • System.Data.Oledb
  • System.Data.SqlClient
  • System.Data.OracleClient
  • System.Data.Odbc

Wednesday, 10 April 2013

Validation Controls

         Validation is the process of verifying whether or not the data given by the user is valid. To perform validations on the page. ASP.net provides a set of controls that are collectively called as validation controls. All the validations controls are available within validation tab in the toolbox. 
         In ASP.net 4.5 and visual studio.net 2012 validation controls perform validations using JQuery. Hence you must add JQuery plugin to your website by downloading it from the website www.jquery.com, which is in form of ,jsfile & then writing the following code within application start event within global.asax file. To add global.asax file to the website right click on the website in solution Explorer & choose add new item & within the add new item dialogbox select "Global Application Class" & then click on add button.

Common properties of validation controls

                     The following is the list of properties common to all validation controls.    
  • ControlToValidate: Used to specify id of the control you want to validate using the validation control.
  • EnableClientScript: This is a Boolean property and is used to specify whether or not clientside validation will be performed by the validation control.
  • Text: Used to specify the error message to display within the validation related to tha validation control fails.
  • Error message: Used to specify the error message to display within the validation summery control.
  • ValidationGroup: Used to specify a group name when you want to divide the validation controls into groups.
Validation controls available in ASP.net are as follows
  • RequiredFieldValidator
  • CompareValidator
  • RegularExpressionValidator
  • RangeValidator         

Sunday, 7 April 2013

FileUpload Control

This control is used to allow the user to select the files and upload them to the server.

Properties of FileUpload Control:
  • AllowMultiple: This is Boolean property & when it is set to true you can select and upload multiple files and when it is set to false then you can select and upload only one file.
  • FileBytes: Returns total content of the file in the form of byte array.
  • FileContent: Returns a string object using which you can read data from the file or write data to the file.
  • FileName: Returns name and path of the selected file.
  • HasFile: This is a Boolean property and it is used to determine whether or not atleast one file is selected in FileUpload.
  • HasFiles: Used to determine whether or not multiple files are selected withen the FileUpload Control.
  • PostedFiles: Returns the first file selected in the FileUpload.
 Method of FileUpload Control:
  • SaveAs: Used to save the selected file onto the server.

Thursday, 4 April 2013

Example: Multi Document Interface







using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WinForms7
{
    public partial class MidParent : Form
    {
        public MidParent()
        {
            InitializeComponent();
        }

        private void form1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form1 f = new Form1();
            f.MdiParent = this;
            f.Show();
        }

        private void arrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void form2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form2 f = new Form2();
            f.MdiParent = this;
            f.Show();
        }

        private void form3ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 f = new Form3();
            f.MdiParent = this;
            f.Show();
        }

        private void cascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.Cascade);
        }

        private void horizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void verticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.TileVertical);
        }
    }
}

Multi Document Interface

  • While desdignng an application it can contain any no. of forms in it, right now to run the desired form we are explicitly specifying the form class name under program class. But when we provide the app to client we only give him the assembies of the project(ie IL code). So client doesnot have a chance to edit the client program and specify the form class name he wants to run.
  • To overcome the above problem we are provided with an approach known as multi document interfaces where in this approach an application will be having on form as a startup form which is refereed to as mdiparent or mdicontainer, so that clients dont require to change the form name under program class at any time. Rest of the forms in app will be under the control of mdiparent form and refered to as mdichilds. To make a form as mdiparent set the property ismdicontainer as true. . Note:An application can have only one mdiparent and all other fprms must be childs of parent which should come and sit under parent. Eg: VS is an mdiparent and launches all other forms like "New Project", "Add New Item" as its childs.
  • To launch a form as child of parent create object of child from class, set its mdiparent property with parent forms reference and then class show() method.
Layout:
  • When we have more than one child forms opened at a time under parent, child forms will be arranged inside the parent by using a layout for arrangement which can be any of the four options like
               - Cascade: Child forms are arranged one on top of the other.
               - TileVertical:  Child forms are arranged one beside the other.
               - TileHorizontal: Child forms are arranged one on top of the other.
               - ArrangeIcons: All child forms are arranged with in the bottom of the parent.