ADO.Net Performance Improvement

Views:
 
Category: Education
     
 

Presentation Description

ADO. Net -Connected and disconnected Architecture.

Comments

Presentation Transcript

ADO .NET:

ADO .NET Study of Connected and Disconnected Architecture Suryoday Tech. 7 th Mar,2013

Connected Architecture:

Connected Architecture The architecture of ADO.net, in which connection must be opened to access the data retrieved from database is called as connected architecture . Connected architecture was built on the classes connection, command, DataReader and transaction. Suryoday Tech. 7 th Mar,2013

Connected Architecture:

Connected Architecture Connection : Connection is used to establish a connection to database and it self will not transfer any data . DataReader : DataReader is used to store the data retrieved by command object and make it available for .net application. Data in DataReader is read only and within the DataReader you can navigate only in forward direction and it also only one record at a time. To access one by one record from the DataReader, call Read() method of the DataReader whose return type is bool. When the next record was successfully read, the Read() method will return true and otherwise returns false. Suryoday Tech. 7 th Mar,2013

Connected Architecture:

Connected Architecture Advantages & Disadvantages : In Connected Architecture you have to declare the connection explicitly by using Open() and close the connection by using Close() and you can execute commands using different methods like ExecuteNonQuery (), ExecuteScalar () and ExecuteReader () . Connected Environment needs constantly connection of user to DataSource while performing any operation. Only one operation can be performed at a time in connected environment. Connected environment is slower in speed. We get updated data in connected environment . Suryoday Tech. 7 th Mar,2013

Disconnected Architecture:

Disconnected Architecture The architecture of ADO.net in which data retrieved from database can be accessed even when connection to database was closed is called as disconnected architecture . Disconnected architecture of ADO.net was built on classes connection, DataAdapter , CommandBuilder and dataset and DataView . Suryoday Tech. 7 th Mar,2013

Disconnected Architecture:

Disconnected Architecture Connection : Connection object is used to establish a connection to database and connection it self will not transfer any data. DataAdapter : DataAdapter is used to transfer the data between database and dataset. It has commands like select, insert, update and delete. Select command is used to retrieve data from database and insert, update and delete commands are used to send changes to the data in dataset to database. It needs a connection to transfer the data. CommandBuilder : by default DataAdapter contains only the select command and it doesn’t contain insert, update and delete commands. To create insert, update and delete commands for the DataAdapter , CommandBuilder is used. It is used only to create these commands for the DataAdapter and has no other purpose. Suryoday Tech. 7th Mar,2013

Disconnected Architecture:

Disconnected Architecture DataSet : Dataset is used to store the data retrieved from database by DataAdapter and make it available for .NET application. To fill data in to dataset fill() method of DataAdapter is used and has the following syntax. Da.Fill(Ds ,”TableName”); When fill method was called, DataAdapter will open a connection to database, executes select command, stores the data retrieved by select command in to dataset and immediately closes the connection. As connection to database was closed, any changes to the data in dataset will not be directly sent to the database and will be made only in the dataset. To send changes made to data in dataset to the database, Update() method of the DataAdapter is used that has the following syntax. Da.Update(Ds ,”Tablename”); Suryoday Tech. 7th Mar,2013

Disconnected Architecture:

Disconnected Architecture When Update method was called, DataAdapter will again open the connection to database, executes insert, update and delete commands to send changes in dataset to database and immediately closes the connection. As connection is opened only when it is required and will be automatically closed when it was not required, this architecture is called disconnected architecture. A dataset can contain data in multiple tables. DataView : DataView is a view of table available in DataSet. It is used to find a record, sort the records and filter the records. By using DataView , you can also perform insert, update and delete as in case of a DataSet. Suryoday Tech. 7th Mar,2013

Disconnected Architecture:

Disconnected Architecture Advantages & Disadvantages : In Disconnected Architecture, you don't need to define the connection explicitly . OracleDataAdopter itself can open and close the connection and you can use dataset for storing the information temporarily and Fill() is used to execute the commands give in adopter. Disconnected environment doesn't need any connection. Multiple operations can be performed at a time in disconnected environment. It has a good speed. In disconnected environment, there is a problem in dirty read. Suryoday Tech. 7th Mar,2013

References & Useful Links:

References & Useful Links MSDN: http://msdn.microsoft.com/en-us/library/ff647768.aspx#scalenetchapt12_topic13 http://helpingdotnet.blogspot.in/2011/10/connected-and-disconnected-architecture.html Suryoday Tech. 7th Mar,2013

authorStream Live Help