Search
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Articles Author
Tue, 02-Sep-2014 Authors
All Time Authors
Sourav.Kayal
39750
Sheonarayan
37300
Niladri.Biswas
33350

Latest members | More ...


(Statistics delayed by 5 minutes)
Ads
 Article

Overview of ADO.NET Classes - Part 2

Naimishforu
Posted by under ADO.NET category on for Beginner level | Points: 250 | Views : 5800 red flag
If you found plagiarised (copied) or inappropriate content,
please let us know the original source along with your correct email id (to communicate) for further action.
Rating: 5 out of 5
2 vote(s)
We will see overview of ADO.NET Classes . This is the second part of the ADO.NET Series article.

Introduction


ADO.NET is described by a set of classes that describe different elements of the data. The DataSet object derives from System.Data.DataSet class, which is used to describe a subset of the overall database. 

The dataset is made up of tables, columns, and rows and is also described by the relations between these objects and the constraints under which they are created.

The Dataset includesDataColumn, Constraints, and DataRow are under the DataTable. DataTable, DataSet, and DataRelation are under the System.Data.

  • DataTable 
  • DataRelation 
  • DataColumn 
  • Constraints 
  • DataRow 

DataTable 

A database table is composed of a set of rows containing data, divided into columns that define that data. In ADO.NET, a DataTable object is used to represent the data of one database table. 

DataRelation 

DataRelation objects describe the relationships between the data columns in different data tables. For example, if one table tracks inventory and another records suppliers, there may be a set of DataRelation objects describing commodities that appear on both tables. 

DataColumn 

Each instance of the DataColumn class describes the data in one column of a DataTable object. Each column can have any number of extended properties, which define the data types and values that can appear in the column. 

The first column in a data table is the primary key for that data table. 

The name of the column is set using the ColumnName property. If no name is specified, a column number will be generated automatically. 

Constraints 

You use a Constraint object to enforce a constraint on one or more DataColumn objects. 

DataRow 

Each instance of the DataRow class describes the data in one row of a data table. A DataColumn object describes a property that a record must have, and a DataRow object describes the set of values that make up a particular record. 

The DataRow class allows you to maintain different versions of the data in a column. This means you can roll back changes made to the table. 

The DataSet, DataTable and DataRelation objects describe the schema definition of a dataset, but this framework must be populated with actual data from the database before it can be worked on. 

This involves the DataAdapter class and the managed providers. Each .NET data provider has a corresponding DataAdapter that you use as a bridge between a data source and a dataset.

A DataAdapter object represents a set of data commands and a database connection that are used to fill the dataset and update the data source. 

Depending on which database you are using, you can use an instance of the SqlDataAdapter or OleDbAdapter classes to transfer information between the dataset and database.

Note

You use the System.Data.SqlClient namespace when you want to work with a SQL Server .NET data provider or the System.Data.OleDb namespace when you want to work with an OLE DB .NET data provider.

Both have methods for populating the dataset and updating the database with changes made to the dataset:

  • Database Connections 
  • Database Commands 
  • Data Readers 

Database Connections 

A database connection object maintains a connection between a dataset and data source. You use OleDbConnection for an OLE DB .NET data provider and SqlConnection for a SQL Server.NET data provider. 

Database Commands 

A database command object lets you send a command, usually a SQL statement or a stored procedure, to the database. You use OleDbCommand for an OLE DB .NET data provider and SqlCommand for a SQL Server .NET data provider. 

Data Readers 

A data reader object allows you to read information directly from the database, without creating a DataSet object. It is not as flexible as using a dataset, because it only allows you to step through each record in turn, but takes up less bandwidth than populating a dataset. You use OleDbDataReader for an OLE DB .NET data provider and SqlDataReader for a SQL Server .NET data provider.

Thanks and Have Fun!!!!!
Page copy protected against web site content infringement by Copyscape
About the Author

Naimishforu

Full Name: Naimish Pandya
Member Level: Bronze
Member Status: Member,MVP
Member Since: 1/22/2011 7:38:35 AM
Country: India
Thanks, Naimish http://dotnetinterview.zxq.net/ http://naimishpandya.blogspot.in/
http://naimishpandya.blogspot.in/

Login to vote for this post.
Found interesting? Add this to:


Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)