Qus: What are the segments of ADO.NET?
1. ADO.Net Data Provider
Connection (connection string): Connection object is used to establish a connection between the database and .Net application, all the database processing is handled once the connection between DB and application created successfully.
Command (Transaction): Command object contains queries like select, update, insert and delete commands which need to be executed on database server. To execute command we need to provide the connection to it and set the command type as below.
DataReader: Data reader is an alternative to the Dataset and DataAdapter combination. Data reader is working on connected mode. We can use it if we need to retrieve data only. It reads data in forward only-read only manner. It’s faster than the DataSet. So these objects are suitable for read-only data access.
Data Adapter(Select, Insert, Update, Delete): Data Adapter is a bridge between database and dataset to transfer data, receive data. It uses select, update, delete command. The select command is used to retrieve data from the database. Insert, update, delete commands are used to update the changes at the database using the dataset. Data Adapter uses the connection object to process all these requests.
There are two types of DataSets
a) Typed DataSet
b) Untyped DataSet
Typed DataSet: is derived from the base DataSet class and then uses information in .xsd file to generate a new class. Information from the schema (tables, columns, and so on) is generated and compiled into this new DataSet class as a set of first-class objects and properties. Typed dataset is easier to read. It’s also supported by IntelliSense in the Visual Studio Code Editor. At compile time, it has type checking so that there are fewer errors in assigning values to DataSet members.
Therefore, using Typed DataSet has many advantages.
Untyped DataSet: is not defined by a schema, instead, you have to add tables, columns, and other elements to it yourself, either by setting properties at design time or by adding them at run time. Typical scenario: if you don’t know in advance what the structure of your program is that is interacting with a component that returns a DataSet.
3. DataTable Collection
Data Table is a collection of DataRow and DataColumn. We can have multiple DataTable in a DataSet.
Data Relation - Data relation can be implemented on different tables on the basis of keys as Parent-Child relation.