C# (Visual studio): Correlation between database, dataset, binding source
Asked Answered
A

3

13

I am just learning C# through Visual Studio 2008?

I was wondering what exactly is the correlation between dabases, datasets and binding sources?

As well, what is the function of the table adapter?

Alerion answered 28/2, 2009 at 20:54 Comment(0)
B
17

At a super high level:

  • Database -- stores raw data

  • DataSet -- a .NET object that can be used to read, insert, update and delete data in a database

  • BindingSource -- a .NET object that can be used for Data Binding for a control. The BindingSource could point to a DataSet, in which case the control would display and edit that data

  • TableAdapter -- Maps data from a database table into a DataSet

There is a lot more to all of these, and understanding the way ADO.NET is architected can take a bit of time. Good luck!

Berzelius answered 28/2, 2009 at 21:22 Comment(0)
S
7

A DataSet is usually used to hold a result from the database in memory, i.e. it contains a DataTable object. The DataSet and DataTable objects themselfs are independent of the database, so the result doesn't have to come from a database. The DataSet can contain several DataTables, and you can even define relations between them. It's like a mini database in memory.

A binding source is any object that can provide a list of objects with properties. A DataSet or a DataTable can do that, but it could basically be any kind of list containing objects that has properties.

A TableAdapter is used to read data from a DataReader provided by a Command object, and put the data in a DataTable object.

Superintend answered 28/2, 2009 at 21:1 Comment(0)
B
4

The dataset is a (partial) in-memory representation of a database. Tables or Views in the datatbase are represented as datatables in a dataset. The dataadapter is the link between the database and the dataset. Once the adapter has loaded the data into the dataset, the physical connection to the dataset is disposed. This is why it's called a disconnected data-model.

Backchat answered 28/2, 2009 at 21:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.