What is Data Adapter, Data Table and Data set?
In this article lets see clearly what's a data adapter(da) , what's a data table(dt) and what's a data set(ds). We may be using it in our projects but many of us wont know what's their definition.
Most of the people would have used Data table, Data set ,Data adapter in their projects in this section lets briefly look into their definitions.What is Data Adapter?
This is the one which communicates with data source and data set , however a data adapter can move any data source to the data set.
Each connection has their own data adapter while you are connected with sql server the sql data adapter will increase the process speed and performance such way each server has its own best data adapters that can be used wisely to get best results in our connection.
Here is the code for creating a sql data adapter,
Dim sql As String = "SELECT * FROM authors"
Dim dataadapter As New SqlDataAdapter(sql, connection)What is a Data Table?
A data table is an in memory representation of a single database table which has collection of rows and columns.
Data table fetches only one Table row at a time.There is no data relation object in it.In data table there is no foreign or primary key and data cannot be serialized.
Code to create a data table in sql for front end vb data grid
Dim Dt = New DataTable()
dataadapter.Fill(Dt)
DataGridView1.DataSource = DtWhat is a Data Set?
A data set is an in memory representation of collection of database tables .
Data set can fetch multiple table rows at a time. Data table objects can be related to each other with data relation objects.
Data set is serialized data source it has unique keys like primary key and foreign key. Here is the code for creating a data set in sql data connection
Dim ds As New DataSet()
dataadapter.Fill(ds)
DataGridView1.DataSource = ds
a DataReader is a forward-only iterator over a set of results. It's usually the most efficient way to deal with records when you don't need random access (in other words you can't go backwards). It is "scalable" to any number of records, at least in terms of memory pressure, since it only loads one record at a time. One typical way to get a DataReader is by using the ExecuteReader method of a DbCommand.
a DataSet represents a set of DataTable objects. More often than not, it will just contain one table, but if you do a query with multiple SELECT statements, the DataSet will contain a table for each. Because this is an in-memory representation, you have to be careful about how much data you pull into a DataSet. You can "Fill" a DataSet using the Fill method of a DataAdapter.
a DataAdapter is a kind of "pipe" that funnels data from a DB engine into a DataSet. That's why you'll have one DataAdapter implementation for each DB provider type. One DataSet, many providers.
a DataView is like a virtual subset of a DataTable