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, dataset and dataview.
Connection: Connection object is used to establish a connection to database and connection itself 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.
Dataset: Dataset is used to store the data retrieved from database by dataadapter and make it available for .net application. A dataset can contain data in multiple tables.
To fill data in to dataset fill () method of dataadapter is used and has the following syntax.
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.
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.
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.
DataRow dr = ds.Tables["userDetails"].NewRow();
dr = txtID.Text;
dr = txtName.Text;
dr = txtRemarks.Text;
MessageBox.Show("Data Saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);