Update Button Click
1. first you need to read data from Excel sheet to DataTable(Using Oledb Provider for Excel)
Connection String for Excel
string Con_Str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DB_Path + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\";";
2. if you want Comparison between u r Database and Excel Sheet Then
Here Fdt means ExcelDataTable and Adt Means u r SqlDataTable
public DataTable CompareDataTable(DataTable Fdt, DataTable Adt)
{
DataTable Cdt = new DataTable();
Cdt = Fdt.Clone();
bool flag = false;
try
{
foreach (DataRow Mrow in Fdt.Rows)
{
var Marray = Mrow.ItemArray;
foreach (DataRow Arow in Adt.Rows)
{
var Aarray = Arow.ItemArray;
if (Aarray.SequenceEqual(Marray))
{
flag = true;
break;
}
else
{
flag = false;
}
}
if (flag == false)
{
Cdt.LoadDataRow(Mrow.ItemArray, LoadOption.PreserveChanges);
}
}
}
catch (Exception ex)
{
}
return Cdt;
}
Now u got Comparison Table Then using foreach loop you can Insert Cdt into Sql at run time
I hope this will help you
If any Query pls Comment
[edit]code block added[/edit]