Wednesday, January 16, 2013

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 As New DataTable()
DataGridView1.Datasource =DT

What 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 = New DataSet()
DataGridView1.Datasource =DS

No comments :

Post a Comment