@Murugavelmsc Sir, Since you tagged with Asp.net , So I am assuming that you are reading the excel data from your Server code like (C#/VB.net) and then you are passing the data to the database and performing a DML operation based on the "EmpID" column. If this assumption is correct, then the approach you can consider is
Step 1: Use
"LinqToExcel" project (
https://github.com/paulyoder/LinqToExcel ). You can use Nuget package manager to do so as
PM> Install-Package LinqToExcel
Step 2: Once done , you can read the data from your excel sheet as shown under (an example)
void ReadEmployeesFromExcel()
{
string excelPath = @"D:\EmployeeRecords.xlsx";
string sheetName = "Sheet1";
var excelFile = new ExcelQueryFactory(excelPath);
var employees = (from a in excelFile.Worksheet(sheetName) select a).ToList();
employees.Foreach(e=>Console.WriteLine(e["EmpID"] +"-----" + e["EmpName"] + "-------" + e["Address"]));
}
Step 3: Assuming you have the SQL Connectivity done in your program(DAL layer through Ado.net Connectivity), you can pass the data to the SP and use Merge Statement (
https://technet.microsoft.com/en-us/library/bb522522(v=sql.105).aspx ) to perform the DML operations.
OR If you are using ORM model (e.g EF), you can use the below code (a pseudocode) for your operation to execute.
public void UpsertEmployee(Employee emp)
{
var empRecord = enSEntities.tblEmployees.Where(e => e.EmpId == emp.EmpId).FirstOrDefault();
if (null != empRecord){
//case for updation
}else{
//case for insertion
}
Hope that helps.
Kindly let us know in case you have any concern for the same.
--
Thanks & Regards,
RNA Team
Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator