ADO.NET has 2 types of objects
Connection
Oriented
Connection Oriented objects works with Specific
provider objects. these objects requires an valid and open connection to
server. Developer has to take the responsbility
to open the connection and close the
connection.
Generally we closes the connection in Finally Block.
Ex:
Fincally
{
Con.Close();
// Connection object
dr.Close();
// DataReader object.
}
Ex:
SqlCommand,SqlDataReader,….ect
Disconnected
Oriented
Coming to Disconnected Oriented objects are
SqlDataAdapter which performs all the operations in disconnected manner. Another
in-memory object is DataSet.
System.Data--àDataSet
System.Data.SqlClientàSqlDataAdapter.
SqlDataAdapter is an object which can work with
Sql-staments as well StoredProcedures also. Which implicitly can open the
connection. And close the connection.(developer no need to care about
connection state/oper[or]close). But we have provide a valid connection object
to SqlDataAdapter.
Like
SqlDataAdapter
internally uses Sqlcommand to perfrom (CRUD operations).
SqlDataAdapter uses Sqlcommand as a base type.
SqlDataAdapter implictly opens the connection.--> Con.State--> open/close automatically.
SqlDataAdapter works with sql-staments and storedprocedures.
SqlDataAdatpeter is transaction object.
SqlDataAdapter can perfrom operations/transactions
in database but this object can't store the data itself. Which uses
DataSet(System.Data).
DataSet is an in-memory
object which stores all the data which is featched from the database.
Dataset is Microsoft-propertary based object.which
can hold the changes by itself till the changes submitted to database(sqlserver
2005/2008).
Dataset stores data as a tables. By default àname
:NewDataset.
And Tables[0];
Dataset can maintain all the features like RDBMS. So
dataset we called as client-side database.
No comments:
Post a Comment