Data set:
1. Dataset is a class, which is the part of
System. Data Namespace
2. Dataset supports connectionless architecture.
That is, active connection is not required while working with datasets
Dataset
cannot communicate directly with database
Hence data adapter is required to carry the data in between dataset and database
àData Adapter is used to carry the data but not to hold the data
àDataset holds a collection of tables, where CLR gives an index number for every table
à Dataset supports to create Relations with the help of primary and foreign keys
àDataset works with the help of xml technology
Hence data adapter is required to carry the data in between dataset and database
àData Adapter is used to carry the data but not to hold the data
àDataset holds a collection of tables, where CLR gives an index number for every table
à Dataset supports to create Relations with the help of primary and foreign keys
àDataset works with the help of xml technology
Data Reader:
àData Reader holds a collection of records
à Data reader is an abstract class
àData Reader is forward only
à Data Reader Is Read-only
àData Readers are connection oriented that is, if connection sate is opened then only data reader works
àIf connection is closed the all associated data readers will be closed automatically
àWhile using data readers, if numbers of clients are more in the network then project efficiency will be decreases
Major Differences
à“Dataset” is a disconnected architecture, while Data Reader has live connection while reading data, if we want to cache data and pass to a different tier “Dataset forms the best and it has decent Xml support.
àWhen application needs to access data from more than one table “Dataset” is the best one
àIf we need to move back while reading records,” Data Reader” does not support functionality
àThe main draw back with dataset is speed. as dataset carry considerable overhead because of relations ,multiple tables etc speed is slower than “Data reader”. Always try to use “Data Reader” wherever possible, as it is meant especially for speed performance.
Syntax for Data Reader:
Sqlconnection con= new sqlconnection();
Con.open();
Sqlcommand com =new sqlcommand (select * from emptable);
Data Reader dr= com.ExecuteReader ( );
Syntax for Dataset:
Sqlconnection con= new sqlconnection();
Con.open();
SqlDataAdapter da =new SqlDataAdapter (select * from emptable);
Dataset ds=new dataset ( );
Da.fill(ds,”newtablename”) // where newtablename is table alias name in dataset
No comments:
Post a Comment