Skip to main content

C Sharp (C#) ADO.NET | Data Set | Data View | Data Table

C Charp (C#) ADO.NET | Data Set | Data View | Data Table


Disconnected Environment:
In ADO.NET, a disconnected environment is one in which an application is not directly connected to a data source.

In this environment, data stored in DataSet and manipulated are performed.

DataSet:

A DataSet is a memory based relational representation of data. It is a part of disconnected environment.

A DataSet is a disconnected, cached set of records that are retrieved from a database.

The data set acts like a virtual database containing tables, rows and columns.

There are two types of data sets: Typed DataSet and Untyped DataSet.

Typed Data set:
A typed DataSet is derived from DataSet classes and has associated XML schemas which is created at the time of creation of the database.

The XML schemas contains information about the DataSet structure such as tables, columns and rows.

Data is transferred from a database into a DataSet and from the DataSet to another component in the XML format.

A typed DataSet structure is stored in an XML format. The DataSet is saved as an XSD file.

The structure of a typed DataSet is decided at the time of its creation.

When a typed DataSet is created, the data commands are generated automatically by using the columns names from the data source.

Tables and their columns can be accessed by using names while programming.

A typed DataSet class contains a public nested class to represent each data table in the DataSet.

A typed DataTable class contains data columns fields. These fields represent the different columns in the data fields.

The DataTable class provides properties which allows you to access these data columns objects directly.

A typed DataSet class contains nested class to represents rows in its data tables.

Untyped Data set:
An untyped DataSet does not have any associated XML schemas. In an untyped DataSet the tables and columns are represented as collection.

The structure of an untyped DataSet is now known during compilation or the data being used not have a f\default structure.

DataSet Object Model:
A DataSet contains a collection of data table and data relation objects. Each data table object contains a collection of rows for representing the data.

A DataRelation object specifies the relationship between the rows for navigation purpose.

A DataTable object also contains unique and foreign key consisting to enforce data integrity.

A DataSet is created with the help of DataSet object. A DataSet object provides an in memory cache of data.

The DataSet class is defined in system data namespace.

The DataSet objects contains a collection of data table objects, each containing one or more tables.

A DataTable object contains one or more columns each represented by a data columns object.

To add a column to a data table, create data column object and call Add() method on column collection.

The column collection enables you to access the columns in a data table.

A DataTable object also has rows collection that allows rows to be accessed in a data set.

A DataTable object contains one or more rows each represented by a data row object.

The Data row has methods : Add(), InsertAt(), Find(), Select(), Remove(), RemoveAt(), Delete().

We can create data relation object for creating the relationship between multiple tables by using primary key and foreign key constraints.

The tables that has a primary key constraints is known as the parent table and the table that has a foreign key constraints is known as child table.

Parent table shows one side relationship and child table shows the many side relationship in a DataSet.

A data set relation property gets the collection of relation that link table and allow navigation from parent tables to child tables.

DataView:
A DataView is a part of the disconnected environment. The System.Data namespace defines the DataView class that enables you to create various views of the data stored in a data table.

A DataView can be used to sort or to filter data in a data table. It can also be used to add, modify, and delete rows in a data table.

A DataView provides a dynamic view of data stored in DataTable. If any data is modified in data table, the data view associated with the data table will also show the modified data.

A DataView is similar to a view in a database. A data view has restrictions: It cannot be treated as a table. It cannot be provide a view of joined database objects.

It cannot excludes columns that exist in the source database.

Creating Data View:
Each DataView object has a default data view object associated with it. To modify the default view for a table the default view property is used to reference the view and then the sorting and filtering properties are enabled.

A DataView object creates a fixed customized view of a given DataTable object by default every table in a DataSet has a data view attached to it.
You can also explicitly create the data view objects in application.

A DataView can display customized data from a data table to a windows application by filtering the data on the basis of a condition.

A DataTable can have multiple data view objects assigned to it, allowing data to be viewed in different ways without having to re-read from the database.

You can define multiple views on the same data table.

Sorting & Filtering Using Data View:
A DataView provides a sorted or filtered view of data in data table.

To specify a sorting order on a single or multiple columns, you can use the sort property of the data view.

To automatically create a sorting ordered, on the basis of the primary key columns or any other columns of the database. You can use apply default sort property of the DataView object.

Comments

  1. Dotnetmastery.com is one of the best and ultimate learning recourses for .NET developers. At our website you can learn lots of E-courses in affordable prices. What our Dot Net Mastery courses offering Job focused Training, Fast Track Learning and much. Visit us today at our official website and get best courses today.

    Learn Entity Framework

    ReplyDelete

Post a Comment

Popular posts from this blog

ADO.NET Framework | Data Binding | Data Table | Data View | Connected and Disconnected Architecture

ADO.NET Framework | Data Binding | Data Table | Data View | Connected and Disconnected Architecture Data Binding Data binding is the ability to bind some elements of a Data Source with the controls of an application. Read : How To Create Connection with Database in SQL Read  :  What is ADO.NET? On the basis of the number of bound, there are two types of binding: Simple Data Binding: Simple Data Binding is the process of binding a control to a single value in DataSet . The DataSet values can be bound to the control by using the properties of the control. Complex Data Binding Complex Data Binding is the process of binding a component (Data Grid View, List Box, and Combo Box) to display multiple values from DataSet .  Complex data binding is the ability to bind a control to more than one record to a data source. The data source property of the control is used to bind the control to a database. Navigation Between Records After binding to...

How To Create Connection With Database in SQL Server

How To Create Connection With Database in SQL Server Creating and Managing Connections To connect to a database for retrieving the data and updating the database, performs the following tasks. 1.     Create a connection object 2.     Create a command object 3.     Open the Connection object, 4.     Execute SQL statements in command object 5.     Close the connection object Creating a CONNECTION object: The connection component of a data providers is used to establish a connection with a Data Source. Read : What is ADO.NET?   To create a connection between User Interface and Data Source, Create a connection object. Read:  Connected and Disconnected Architecture of ADO.NET Use SqlConnection class to open the connection of Microsoft SQL Server Database . After creating the connection object, Use ConnectionString property provides the ...

Data Adapter and Data Set in ADO.NET

Data Adapter and Data Set in ADO.NET Data Adapter : DataAdapter is a part of the connected environment. A DataAdapter is integral to the working of ADO.NET because of data is transferred to and from a database through a DataAdapter . Read  :  How To Create Connection with Database in SQL Read  :  What is ADO.NET? Read   :   D ata Table and Data View in ADO.NET A DataAdapter retrieves data from a database and store into a DataSet . When you make changes to DataSet the changes in the database are actually done by the DataAdapter . The DataAdapter first compares the data in the DataSet with that in the database and then updates the database. DataAdapter that can be configured to connect to a database in visual studio NET. A DataAdapter uses the connection objects SqlConnection , OleDbConnection , OdbcConnection , OracleConnection to communicate with the database. A DataAdapter communicates with a database ...