Hi,
You can read Every sheet at a time and then every row at a time in a sheet and u can update to the DB in 2 ways
1. Form a xml as and when you read the date from excel and send this xml to the DB and do the updation using openxml in SQL server, here the round trips are just the number of sheets in the excel file.
2. Read each row from a single sheet and update the database immediately. Add reference to excel object in your project
Excel.Application objwb = null;
Excel.Workbook wb = null;
Excel.Sheets sheets = null;
Excel.Range range = null;
Excel.Worksheet WSheet = null;
objwb = new Excel.Application();
wb = objwb.Workbooks.Open(<YOUR
sheets = wb.Worksheets;
WSheet = sheets.get_Item(<YOUR SHEET INDEX>) as Excel.Worksheet;
range = WSheet.get_Range("A" + i.ToString(), "L" + i.ToString()); //SET RANGE(columns) TO READ FROM A ROW
System.Array myvalues = (System.Array)range.Cells.
// myvalues.GetValue(1, 1) Will give the value of second row , First Column Cell value.
-AP
Main Topics
Browse All Topics





by: jandromedaPosted on 2008-03-11 at 04:43:59ID: 21094703
You can get an idea from the code given below. And another thing you can do is write a SSIS package to do that transform. I think this would be that easiest.
Select allOpen in new window