Which is the best to retrieve Read-Only, Forward-only stream of data from database
-
Data Set
-
Typed Data Set
-
DataReader
DataReader provides a read-only, forward-only stream of data from a database, making it ideal for scenarios requiring high-performance sequential access. DataSets (A, B) load entire result sets into memory, which is inefficient when you only need to read data once sequentially.
To answer this question, you need to understand the different ways to retrieve data from a database.
Option A) Data Set - This option is incorrect because a Data Set is an in-memory representation of data that allows you to store and manipulate data from multiple tables. It is not specifically designed for retrieving a read-only, forward-only stream of data.
Option B) Typed Data Set - This option is incorrect because a Typed Data Set is a subclass of a Data Set that provides strongly-typed access to the data. Like a regular Data Set, it is not specifically designed for retrieving a read-only, forward-only stream of data.
Option C) DataReader - This option is correct because a DataReader is a lightweight, forward-only, read-only stream of data from a database. It provides efficient access to data by retrieving one row at a time, which is useful when you only need to read the data and do not need to modify it. The DataReader is commonly used when performance is a concern or when working with large result sets.
The correct answer is C) DataReader. This option is correct because it provides a read-only, forward-only stream of data from a database.