Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

.Net Technologies Notes, Study notes of Computer Science

The use of DataAdapter and DataSet in ADO.NET. DataAdapter is used to retrieve data from a database and places the results into a DataSet or DataTable. The DataSet is an in-memory data store that can hold multiple tables and is used to fetch data without interacting with a data source. The SQLDataAdapter is used to handle the connection with the data source and manages disconnected behavior. This document also explains the standard mechanism of disconnected data architecture and how it makes the application more scalable.

Typology: Study notes

2021/2022

Available from 03/26/2023

srushti-dewalekar
srushti-dewalekar 🇮🇳

5 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
DataAdapter :-
Data Adapter has select command property which is used to retrieve data from database.
DataAdapter places results of query into DataSet/ DataTable.
It also has delete update and insert command.
Data Adaper has fill() method to populate DataSet object with data that SQLDataAdaper object
retrieves from database.
• Syntax of fill.
• da.Fill(ds,”emp”);
We have disconnected data access using dataset and sqldataadapter objects.
A dataset is considered as in memory data store which can store numerous tables.
Datasets are used to hold the data. They do not interact with database / data source.
The SQL data adapter is used handle connection with data source and manages disconnected
behaviour.
The most important is that connection is open by SQL data adapter when needed and closed as
soon as operation is accomplished.
eg. To fill dataset following steps are performed by SQL DataAdapter.
• Step1) Open connection
• 2) Retrieve data into dataset.
• 3) Close connection.
To Update dataset with data source changes following steps are performed.
• 1) open connection
pf3
pf4
pf5

Partial preview of the text

Download .Net Technologies Notes and more Study notes Computer Science in PDF only on Docsity!

  • DataAdapter :-
  • Data Adapter has select command property which is used to retrieve data from database.
  • DataAdapter places results of query into DataSet/ DataTable.
  • It also has delete update and insert command.
  • Data Adaper has fill() method to populate DataSet object with data that SQLDataAdaper object retrieves from database.
  • • Syntax of fill.
  • • da.Fill(ds,”emp”);
  • We have disconnected data access using dataset and sqldataadapter objects.
  • A dataset is considered as in memory data store which can store numerous tables.
  • Datasets are used to hold the data. They do not interact with database / data source.
  • The SQL data adapter is used handle connection with data source and manages disconnected behaviour.
  • The most important is that connection is open by SQL data adapter when needed and closed as soon as operation is accomplished.
  • eg. To fill dataset following steps are performed by SQL DataAdapter.
  • • Step1) Open connection
  • • 2) Retrieve data into dataset.
  • • 3) Close connection.
  • To Update dataset with data source changes following steps are performed.
  • • 1) open connection
  • • 2) Write changes from DataSet to DataSource.
  • • 3) close connection.
  • After filling dataset , datasource connection can be closed before update operation. Even after closing connection we can read and write data in DataSet as per requirement. Even after closing connection we can read and write data in dataset as per requirement.
  • • This is standard mechanism of disconnected data architecture.
  • • The application becomes more scalable as connection is held by application only when required.

• DataSet :-

  • It is a collection of data tables that contain the data. It is used to fetch data without interacting with a Data Source that's why, it also known as disconnected data access method.
  • It is an in-memory data store that can hold more than one table at the same time. We can use DataRelation object to relate these tables. The DataSet can also be used to read and write data as XML document.
  • ADO.NET provides a DataSet class that can be used to create DataSet object. It contains constructors and methods to perform data related operations.
  • Example:

**</asp:GridView>

**
  • CodeBehind // DataSetDemo.aspx.cs using System; using System.Data.SqlClient; using System.Data; namespace DataSetExample { public partial class DataSetDemo : System.Web.UI.Page { protected void Page_Load( object sender, EventArgs e) { using (SqlConnection con = new SqlConnection("data source=.; database=student; integrated security=SSPI")) { SqlDataAdapter sde = new SqlDataAdapter("Select * from student", con); DataSet ds = new DataSet(); sde.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); } } } }