3
Reply

What is the difference b/w Dataset and DataReader?

    DataReaderDataReader is used to read the data from database and it is a read and forward only connection oriented architecture during fetch the data from database. DataReader will fetch the data very fast when compared with dataset. Generally we will use ExecuteReader object to bind data to datareader.DataSetDataSet is a disconnected orient architecture that means there is no need of active connections during work with datasets and it is a collection of DataTables and relations between tables. It is used to hold multiple tables with data. You can select data form tables, create views based on table and ask child rows over relations. Also DataSet provides you with rich features like saving data as XML and loading XML data.

    Data Reader: 1- Data reader works on a connection oriented architecture. 2- Data reader is read only and forward only that means data reader reads only one record at a time, and after reading the current record it moves to the next record.There is a no way to you can go back to previous record.Its only read record on forward direction 3-Updation is not possible with Data Reader. 4- Its read only and forward only .so it is faster than Data set.Data-Set 1-Data-set works on disconnected architecture. 2- Data set reads record on both direction means forward and backward direction. 3-Database is updated from data set. 4-It is slower than data reader

    The DataReader only stores one result at a time on the client. This results in a significant reduction in memory usage and system resources when compared to the DataSet, where the whole query is stored. In other words we can say that reader is like interpreter and dataset is compiler. Another thing if we use datareader then it is necessery to open the connection and after execution the command we close the connection. But dataset automatically open the connection and close the connection. Can make changes in dataset while datareader is only for reading , moreover u can move only in forward direction in case of data reader and also can jump to next record only and cna not jump to any specific record, which is off course possible in dataset.