ADO.NET is a data access protocol that utilizes a disconnected architecture, primarily using data connections, data adapters, and datasets to manage data. It supports various data providers, with Microsoft's SQL Server being the default, and employs XML for defining dataset structures and transferring data. Key objects in ADO.NET include DataTable, DataReader, DataView, and various command and constraint objects that facilitate data manipulation and integrity checks.
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
3 views
ADO.NET
ADO.NET is a data access protocol that utilizes a disconnected architecture, primarily using data connections, data adapters, and datasets to manage data. It supports various data providers, with Microsoft's SQL Server being the default, and employs XML for defining dataset structures and transferring data. Key objects in ADO.NET include DataTable, DataReader, DataView, and various command and constraint objects that facilitate data manipulation and integrity checks.
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16
ADO.
NET (ADO stands for ActiveX Data Objects)
as its primary data access and manipulation protocol. • There are plenty of objects available in ADO.NET • first get a connection to a data source, which means using a data provider to access a database. • default data provider is Microsoft's SQL Server, version 7.0 or late • data provider that can support Open Database Connectivity (ODBC), such as Oracle • There are the three objects that are essential: • data connections to connect to the database, • data adapters to execute SQL with, and • datasets to store the data—as returned from data adapters. • ADO.NET uses a disconnected data architecture, which means that the data you work with is just a copy of the data in the data in the actual database • To store the data you work with in your application, we use datasets, which represent a sort of data cache of records • The data in the dataset is usually a much-reduced version of what is in the database. • it in much the same way you do the real data. • Datasets are really just passive containers for data. • To actually get data from a database and write it back, you use data adapters. • A data adapter contains the instructions for populating a single table in the dataset and updating the corresponding table in the database • dataset acts as a cache for data drawn from a database, the dataset has no actual direct relationship with the database. • The dataset is a container; it is filled by SQL commands or stored procedures executed from a data adapter.
• refresh the dataset by calling the Fill method.
• ADO.NET needs some way of defining the structure of a dataset using XML. • The actual structure—that is, what tables, columns, data types, constraints, and so on are in the dataset—is set up with an XML schema. • ADO.NET uses XML as the format for transferring data. Similarly, if data needs to be saved Overview of ADO.NET Objects • Here's a list of the most common ADO.NET objects: • Data connection objects—To work with a database, we must have a data connection. • A data adapter needs a connection to a data source to read and write data, and it uses OleDbConnection or SqlConnection objects to communicate with a data source. • Data adapters—Data adapters are a very important part of ADO.NET. • We use them to communicate between a data source and a dataset. • We typically configure a data adapter with SQL to execute against the data source. • The two types of data adapters are OleDbDataAdapter and SqlDataAdapter objects. • Command objects—Data adapters can read, add, update, and delete records in a data source. • To allow you to specify how each of these operations work, a data adapter contains command objects for each of them. • Data adapters support four properties that give you access to these command objects: SelectCommand, InsertCommand, UpdateCommand, and DeleteCommand. • Datasets—Datasets store data in a disconnected cache. • The structure of a dataset is similar to that of a relational database; it gives access to an object model of tables, rows, and columns, and it contains constraints and relationships defined for the dataset. • Datasets are supported with DataSet objects. • DataTable objects—DataTable objects hold a data table from a data source. • Data tables contain two important properties: Columns, which is a collection of the DataColumn objects that represent the columns of data in a table, and • Rows, which is a collection of DataRow objects, representing the rows of data in a table. • Data readers— DataReader objects hold a read-only, forward-only (i.e., we can only move from one record to the succeeding record, not backwards) set of data from a database. Using a data reader can increase speed because only one row of data is in memory at a time.
• Data views—Data views represent a customized
view of a single table that can be filtered, searched, or sorted. In other words, a data view, supported by the DataView class • Constraint objects—Datasets support constraints to check data integrity. • A constraint, supported by the Constraint class, is a rule that can be used when rows are inserted, updated, or deleted to check the affected table after the operation. • There are two types of constraints: • unique constraints check that the new values in a column are unique throughout the table, and • foreign-key constraints specify how related records should be updated when a record in another table is updated. • DataRelation objects—DataRelation objects specify a relationship between parent and child tables, based on a key that both tables share.
• DataRow objects—DataRow objects correspond to a
particular row in a data table. We use the Item property to get or set a value in a particular field in the row.
• DataColumn objects—DataColumn objects
correspond to the columns in a table. Each object has a DataType property that specifies the kind of data each column contains, such as integers or string values