aspday8

16
DATABASE CONNECTIVITY IN .NET ADO COM BASED MODEL ADO.NET NAME SPACE MODEL

Upload: srikanth

Post on 13-Sep-2015

212 views

Category:

Documents


0 download

DESCRIPTION

ASPDay8

TRANSCRIPT

  • DATABASE CONNECTIVITY IN .NETADOCOM BASED MODELADO.NETNAME SPACE MODEL

  • ADO.NETCONNECTION ORIENTED MODELDISCONNECTED ORIENTED MODEL

  • CONNECTION ORIENTED MODELWhenever an application uses the connection oriented model to interact with the db then the connectivity between the application and the database has to be maintained always.

  • Connection OrientedWhenever an user executes any statement other than a select then command object can be binded directly to the applicationIf the user executes a select statement then dataReader is used to bind the result to the application.ApplicationdbConnectionCommandData ReaderDATA PROVIDERS

  • Disconnected Oriented Model in ADO.netWhen the user interacting with the db using this model then while performing the manipulations or navigations on the data connectivity between the application and the database is not requiredNote: When ever the data is been updated on to the database then the connectivity is required in the disconnected model.

  • DISCONNECTED MODELDatabaseDataSetApplicationData AdapterConnectionData ViewData ProvidersThis is available in client system

  • Disconnected ModelConnection it is used to establish the physical connection between the application and the databaseDataAdapter it is a collection of commands which acts like a bridge between the datastore and the dataset.Commands in DataAdapter Select CommandTable MappingsInsert CommandUpdate CommandDelete CommandDataAdapterCollection of all these commands is DataAdapterFill(Dataset Name[,DataMember])Update(Dataset Name[,DataMember])

  • Points to remember about DataAdapterDataAdapter can always be binded to a single table at a time.Whenever the dataAdapter is used then implicit opening and closing of connection of closing object will take place.If the dataAdapter is defined using a tool or a control then all the commands for the adapter will be defined implicitly provided the base table with a primary key.If the base table is not defined with a primary key then the commands relevant for update command and Delete command will not be defined.

  • Fill MethodIt is used to fill the data retrieved by the select command of DataAdapter to the dataset.Data AdapterdbSelect CommandSelect * from empFill(ds,emp)DS

  • Update MethodIt is used to update the dataAdapter with the data present in the dataMember of the dataSet.In other words used to the update the database.Data AdapterdbUpdate(ds,emp)DS

  • DataSetIt is an in memory representation of the data in the format of XML at the client system.Points to remember about DataSet:It contains any no of datatables which may belong to the same or different databases also.If any manipulation are performed on the database it will not be reflected on to the database.Dataset is also considered as a collection of datatables where a datatable can be considered as a DataMember.Dataset will not be aware of from where the data is coming from and where the data will be passed from it.Dataset supports establishing the relationship between the datatables present in the dataset where the datatables might belong to different databases also.

  • Data SetDataSet is of 2 types Typed DataSet when ever the dataset is defined with the support of XML schema definitions then it is said to be typed dataSet.UnTyped DataSet if the dataset is defined without the XML Schema Definition then it is said to be UnTyped DataSet.

  • DataViewIt is logical representation of the data present in the datamember of dataSet.Usage It is used to sort the data,filter the data or if the data has to be projected in the pagewise then the dataView should be used.

  • CommandIt is used to provide the source for executing the statement I.e it used to specify the command to be executed.

  • Data ReaderIt is a forward and read only record set which maintains the data retrieved by the select statement.

  • ADO.NETDISCONNECTED MODELCONNECTION ORIENTED MODELCONNECTIONDATA ADAPTERDATA SETDATA VIEWUICONNECTIONCOMMANDDATA READERUIUsed if the data has to be filtered, sorted or if the data has to be projected in page-wiseUsed if the statement is select statement