Year End Sale: Get Upto 40% OFF on Live Training! Offer Ending in
D
H
M
S
Get Now

ADO.NET with ASP .NET Core In Disconnected Environment

Level : Advanced
Mentor: Shailendra Chauhan
Duration : 00:01:00

ADO.NET Disconnected Approach

The ADO.NET Disconnected Approach in ASP.NET Core allows developers to retrieve and manipulate data from a database without keeping a continuous connection open. It involves fetching data into disconnected datasets or data tables, making changes, and then updating the database in a batch.

Example

// Fetch data into a disconnected DataTable
using (SqlConnection connection = new SqlConnection(connectionString))
{
  SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Customers", connection);
  DataTable dataTable = new DataTable();
  adapter.Fill(dataTable);
  // Perform operations on the DataTable
  // ...
  // Update changes to the database
  adapter.Update(dataTable);
}

Disconnected Fetching Data

Disconnected fetching of data in ASP.NET Core is a technique where data is retrieved from a database and stored in a local data structure, like a DataTable or a List, for offline manipulation and processing.

Example

using (SqlConnection connection = new SqlConnection(connectionString))
{
  SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Products", connection);
  DataTable dataTable = new DataTable();
  adapter.Fill(dataTable);
  // Data is now available in the 'dataTable' for offline processing
}

Disconnected Inserting Data

Disconnected data insertion in ASP.NET Core involves adding new data records to a local data structure, such as a DataTable, and then updating the database in a batch when necessary.

Example

// Create a new DataRow and add it to a DataTable
DataRow newRow = dataTable.NewRow();
newRow["ProductName"] = "New Product";
newRow["Price"] = 50.0;
dataTable.Rows.Add(newRow);
// Later, update the database to insert the new data
adapter.Update(dataTable);

Disconnected Fetch Specific Data

In the Disconnected Approach of ASP.NET Core, you can fetch specific data by applying filters or conditions to the data stored in local data structures like DataTables.

Example

using (SqlConnection connection = new SqlConnection(connectionString))
{
  SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Orders", connection);
  DataTable dataTable = new DataTable();
  adapter.Fill(dataTable);
  // Filter data to fetch specific records
  DataRow[] specificRows = dataTable.Select("OrderDate > '2023-01-01'");
  // 'specificRows' now contains records that meet the condition
}
Self-paced Membership
  • 24+ Video Courses
  • 825+ Hands-On Labs
  • 400+ Quick Notes
  • 125+ Skill Tests
  • 10+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this