Dataset object in ADO .NET


Unknown | 03:36 |

Dataset object in ADO .NET

The DataSet object is a disconnected storage.DataSet is a disconnected  in-memory representation of data. It can be considered as a local copy of the relevant portions of the database. The DataSet is persisted in memory and the data in it can be manipulated and updated independent of the database. It represents related tables, constraints, and relationships among the tables. DataSet reads and writes data and schema as XML documents.The DataSet object is a disconnected storage.It is used for manipulation of relational data. The DataSet is filled with data from the storeWe fill it with data fetched from the data store. Once the work is done with the dataset, connection is reestablished and the changes are reflected back into the store.
                                
                                    
          
ADO.NET DataSet can contain more than one table and also contains information about table relationships, the columns they contain, and any   constraints that apply. Each table in a DataSet can contain multiple rows. Once data is retrieved from the database into a DataSet object, an application can disconnect from the database before processing the DataSet. This is an important feature of the ADO.NET DataSet. It gives us an in-memory, disconnected copy of a portion of the database which we can process without retaining an active connection to the database server.

Creating and using a DataSet

The typical steps in creating and using a DataSet are:
(i)Create a DataSet object
(ii) Connect to a database
(iii)Fill the DataSet with one or more tables or views
(iv)Disconnect from the database
(v)Use the DataSet in the application


Example of  DataSet


using System;
using System.Data;
using System.Data.SqlClient;
public class empcount {
public static void Main() {
// change the following connection string, as necessary...
string con =
@"server=(local)\kamal;database=Emp;trusted_connection=yes";
DataSet ds = new DataSet("EmpDataSet");
SqlDataAdapter sad;
string sl;
sl = "SELECT COUNT(*) AS cnt FROM employee";
sad = new SqlDataAdapter(sl, con);
sad.Fill(ds, "emp_count");
sl = "SELECT COUNT(*) AS cnt FROM compocation";
sad = new SqlDataAdapter(sl, con);
sad.Fill(ds, "comploc_count");
int totalemp = (int) ds.Tables["emp_count"].Rows[0]["cnt"];
int comploc = (int) ds.Tables["comploc_count"].Rows[0]["cnt"];
Console.WriteLine(
"There are {0} employee, {1} complocation .",
totalemp ,
comploc,

);
}
}

7 comments:

{ Unknown } at: 3 September 2015 at 03:05 said...

Thanks for your informative article and the blog. Your article is very useful for .net professionals and freshers looking for interview. Best DOT NET Training | Dot Net course Chennai

{ Unknown } at: 15 May 2017 at 22:07 said...

The detailed description about the dataset object in ADO.Net was very much useful and helpful My Sincere Thanks for sharing this post
Dot Net Training in Chennai

{ user123 } at: 7 March 2019 at 22:23 said...

Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
Data Science Training in Chennai
Robotic Process Automation Training in Chennai
Cloud Computing Training in Chennai
Data Warehousing Training in Chennai
Dev Ops Training in Chennai

{ Softlogicseo } at: 6 June 2019 at 05:34 said...

It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
Data Science Training in ChennaiKK Nagar | Data Science Course in Chennai
Python Course in Chennai KK Nagar | Python Training Course Institutes in Chennai
RPA Training in Chennai KK Nagar | RPA Training in Chennai

{ Softlogicseo } at: 6 June 2019 at 05:38 said...

It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
Data Science Training in ChennaiKK Nagar | Data Science Course in Chennai
Python Course in Chennai KK Nagar | Python Training Course Institutes in Chennai
RPA Training in Chennai KK Nagar | RPA Training in Chennai

{ Ajish } at: 18 July 2019 at 03:14 said...

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
Dot Net training in Electronic City

{ deiva } at: 3 September 2020 at 06:33 said...

It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
sap training in chennai

sap training in omr

azure training in chennai

azure training in omr

cyber security course in chennai

cyber security course in omr

ethical hacking course in chennai

ethical hacking course in omr

Post a Comment