AspnetO

We code, that works!

  • Home
  • Asp.net
  • MVC
  • Interview Questions
You are here: Home / Asp.net / Difference: A Complete Guide DataSet vs DataTable in .NET

Difference: A Complete Guide DataSet vs DataTable in .NET

By: Mayank Modi | Falls In: Asp.net, C#, Interview Questions, VB | Last Updated: Oct 10, 2020

Now here in this tutorial, I’ll explain the main differences between dataset vs datatable as well as show you how to use dataset or datatable with an example.

In my previous tutorials, I’d explained the difference between dataset and datareader, difference between string and stringbuilder, difference between dataset datareader dataadapter and dataview, difference between executereader executenonquery and executescalar, OOP concepts with examples and other similar tutorials on difference here.

 

Let’s start with the difference between DataSet vs DataTable.

Difference: DataSet vs DataTable

Well, you are looking for the difference between dataset vs datatable, Right?

If so, that means that you are asking for the difference between you and your team that play for same team in sports.

Got my point?

If not, then don’t worry, let me explain clearly with an example.

Ultimately, DataSet is a container of one or more DataTable. For instance, Consider DataSet is a captain of your team and DataTables are other players including you in your team. So, it is like you are asking the difference between you and your team.

By the way, it was just an example for fun. 😉

Now come to the point, following are the list of possible differences between DataSet vs DataTable:

DataSet DataTable
A DataSet contains a collection of one or more database tables which resides in-memory A DataTable contains a single database table which resides in-memory
It has a collection of datatables It has a collection of rows and columns
DataSet is a collection of DataTable objects, so there could be a relation between each other to get specific results DataTable is a single database table, so there is no possibility about relation
It can fetch multiple TableRows at a same time It can fetch only one TableRow at a same time
DataSource objects are serialized in DataSet. For example, Web Services always returns DataSet as the resultset DataSource objects are not serialized in DataTable

Using DataTable and DataSet in Asp.net with Example

Use following code for C#:

//declare collection of datatables
DataTable dt1 = new DataTable();
DataTable dt2 = new DataTable();

//declare dataset and add collection of datatables
DataSet ds = new DataSet();
ds.Tables.Add(dt1);
ds.Tables.Add(dt2);

Use following code for Vb.net:

‘declare collection of datatables
Dim dt1 As New DataTable()
Dim dt2 As New DataTable()

‘declare dataset and add collection of datatables
Dim ds As New DataSet()
ds.Tables.Add(dt1)
ds.Tables.Add(dt2)

Signup Today And Get Latest Tutorials For Free!

Subscribe to us and get free latest tutorials notifications whenever we publish a new contents.

<

About Mayank Modi

Mayank is a web developer and designer who specializes in back-end as well as front-end development. He's a Founder & Chief Editor of AspnetO. If you'd like to connect with him, follow him on Twitter as @immayankmodi.

Leave a Reply Cancel reply

Search Your Topic



Social Connections

  • 1,438 Fans
  • 3,098 Followers
  • 51 Followers
  • 1,559 Subscribers

Get Latest Tutorials For Free



Top Posts

  • CSS3 Transition: fadeIn and fadeOut like Effects to Hide Show Elements
  • Asp.net TextBox: How to Get Set TextBox Value or Text in JavaScript
  • Show Confirm Message Box from Code-behind in Asp.net
  • Show Alert Message Box from Code-behind in Asp.net C# Vb
  • Top 10 OOPS Concepts In C# .NET With Examples

Contribute to AspnetO

If you want to contribute your unique blog articles or tutorials (Free / Paid) to AspnetO in any languages, you're most welcome. Just send me your previous articles, and topics on which you are interested to post an tutorial. Contact us at email listed in contact us page. Selected candidates will be contacted.

Search by Tags

Ado.net Ajax appSettings Asp.net C# CheckBox CheckBoxList ConnectionStrings Control CSS CSS3 Difference Download DropDownList Export Facebook fadeIn fadeOut fadeTo fadeToggle File File Extension FileUpload Function GridView IIS Interview Questions JavaScript jQuery MVC OOP RadioButtonList RDP Repeater Send Mail Solutions Split SQL Stored Procedure TextBox Upload Validation VB Web.config Web Hosting

The Man Behind AspnetO

Mayank Modi

Hi there,

Myself Mayank Modi, a Full Stack Developer (.NET Stack) and a blogger from Surat, India.

I'm welcoming you to my blog - AspnetO, a programmers community blog where we code, that works!

I started AspnetO as a hobby and now we're growing day by day. We're now having 5000+ programmers that get benefits and learn new things about website design and development under our community blog.

Here at AspnetO, I write about Beginners to Advance level of tutorials on programming languages like Asp.net using C# and Vb.net, MVC, SQL Server, JavaScript, jQuery etc. In sort, all about .NET Framework and website development stuff and sometimes sharing tips and tricks that can help you to grow up your programming skills.

You can get more details about me and my blog at About us page.

Subscribe To Newsletter

Enter your email address to subscribe to this blog and receive notifications of new posts right to your inbox

Join 1000+ other subscribers

<

Recent Posts

  • Main Difference between SessionState and ViewState in Asp.net
  • How to Get appSettings Value from Web.config File?
  • How to Get ConnectionString from Web.config in Asp.net?
  • Difference between appSettings and connectionStrings in Web.config
  • Get Folder Files List and Export to CSV in .NET
  • Get Files List From Directory Recursively in C# Vb.net
  • Get Hash Value From Current Page URL In jQuery
  • Handle Multiple Submit Buttons in Single MVC Form

Copyright © 2014 - 2021 · All Rights Reserved.

About | Copyrights | Privacy | Terms | Contact | Advertise | Sitemap
Previous Difference: Website vs Web Application – Which is best?
Next Difference: A Complete Guide DataSet vs DataReader in .NET