One of the options is to create a
Strongly Typed DataSet
using the
AddNewDataSource
wizard of
VisualStudio
. This wizard generates the
DataSet
and
DataTables
corresponding to the
Tables
in the
MS SQL Server
. It also creates
TableAdapter
for each of the
Table
for filling the data and updating all the rows of the
DataTable
to the corresponding
Table
in
MS SQL Server
.
Connecting to
Data
is explained here
Connecting to Data in Visual Studio Overview [
^]
Data Source Configuration Wizard[
^]
One problem with this approach is that for filling the data into the
DataTable
and saving the data from the
DataTable
to the database the
TableAdapter
corresponding to the
DataTable
is to be used as the
DataTables
and
TableAdapters
are strongly typed.
However, using
reflection
a common class can be written to handle the filling and saving data for all or some
DataTables
. Such class is given in this CodeProject article
General purpose class to fill DataTable(s) from DataBase and to save DataTable(s) to DataBase using reflection[
^]
Binding the data to
DataGridView
is explained here
How to: Bind Data to the Windows Forms DataGridView Control Using the Designer [
^]
I think it may be helpful.