I want to insert data from Excel into SQL Server. I have written code but the values are not being read from Excel:
System.Data.DataTable dt = new System.Data.DataTable();
Workbook WB = Globals.ThisAddIn.Application.ActiveWorkbook;
Sheets worksheets = WB.Worksheets;
lastrow = WB.ActiveSheet.UsedRange.Rows.Count;
for(int i = 2; i<= lastrow; i++)
{
cmd.CommandText = ("INSERT Table_1 (emp_no,emp_name,salary) values (WB.Cells[i , 1] , WB.Cells[i , 2] , WB.Cells[i , 3]))");
}
INSERT INTO Table_1 ...?