ADO.NET Object Model

The .NET Framework is designed to change dramatically the developer's current style of developing applications, including the data access features. For the .NET applications, the primary data access technology to be used would be ADO.NET — the latest addition to the ADO model.

The ADO.NET Object Model is primarily divided into two levels:

Connected Layer: Consists of the classes that comprise the Managed Providers
Disconnected Layer: Is rooted in the DataSet

Managed Providers

Managed Providers are a collection of classes in the .NET Framework that provide a foundation for the ADO.NET programming model. The .NET Framework allows you to write language-neutral components, which can be called from any language, such as C++ or Visual Basic. In the .NET Framework, the OLE DB and ADO layers are merged into one layer. This results in high performance, and at the same time allows components to be called from any language. The Managed Data Providers include classes that can be used for the following:

Accessing data from SQL Server 7.0 and later

Accessing the other OLE DB providers

The Managed Provider for ADO.NET is the System.Data.OleDb namespace, which allows you to access OLE DB data sources. This namespace includes classes that are used to connect to OLE DB data sources and execute database queries to access and manipulate data.

To demonstrate how to open a connection to a SQL Server database and fill the DataSet with a database query result, consider the following code:

Dim connection As New

SqlConnection("server=localserver;uid=sa;pwd=;database=Sales")
Dim command As New SqlDataAdapter("SELECT * FROM Products Where
ProductID=@ID", connection)
Dim param1 As New SqlParameter("@ID", SqlDbType.Int)

param1.Value = 1
command.SelectCommand.Parameters.Add(param1)
Dim dataset As New DataSet()
command.Fill(dataset, "Products")
In this code:

connection is a SqlConnection class object that represents a connection to the SQL Server database.

command is a SqlDataAdapter class object that represents a set of data commands and a database connection.

param1 is a SqlParameter class object that represents the parameter to be passed in the T-SQL command.

dataset is a DataSet class object that represents the DataSet that is filled by the query results.

DataSet class

The DataSet comprises the Disconnected Layer of ADO.NET. The DataSet consists of a local buffer of tables and relations. the DataSet object model consists of Tables, Columns, Relations, Constraints, and Rows. A DataSet contains a collection of DataTables (the Tables collection). A DataTable represents one table of inmemory data. A DataTable consists of the following:



Unlike RecordSets, which are equivalent to tables in ADO, DataSets keep track of the relationships between tables if any. The DataSet is designed with a rich programming model. Th e following code creates a new DataTable with the name ProductInfo:

Dim dset As DataSet = New DataSet("ProductInfo")

Later, you can add columns to the DataTable. The columns are added to the DataTable by using the Add method on the Columns collection, and the column is assigned a name and a datatype. Finally, data is added to the table by calling the NewRow method on the DataTable and storing the column values in each DataRow.

RELATED POST

CREATING ASSEMBLIES WITH ASP.NET

BUILDING HANDLERS IN ASP.NET

INTERFACES AND CLASSES CREATION IN ASP.NET

CACHING IN ASP.NET

CACHING IN ASP.NET PART TWO

WIRE LESS APPLICATION WITH ASP.NET

SECURITY IN ASP.NET PART ONE

SECURITY IN ASP.NET PART TWO

LOCALIZING ASP.NET APPLICATIONS

DEPLOYING ASP.NET APPLICATIONS

ASP.NET CONFIGURATION SYSTEM

WEB SERVICES IN ASP.NET

WEB SERVICES PART TWO

WEB SERVICE INFRASTRUCTURE

WEB SERVICE INFRASTRUCTURE PART TWO

EXCHANGING MESSAGES IN ASP.NET

MICROSOFT HAIL STORM

SOAP AND DOT NET PART ONE

SOAP AND DOT NET PART TWO


No comments:

Post a Comment