Skip to main content

Posts

Showing posts from March, 2014

Import Data from Excel to SQL Server ASP.NET MVC

I want to save the excel sheet data in my SQL or other database. In this sheet you just mind the name of the table Sheet1. Now the controller public ActionResult ManualAttendence() { return View(); } And the ManualAttendence view @using (Html.BeginForm("ManualAttendence", "AttendanceManual", FormMethod.Post, new { enctype = "multipart/form-data" })) { <input type="file" name="file" /> <input type="submit" value="OK" /> } Create a new folder name ManualAttendenceSheet in your solution App _ Data folder. Now brows the file & click ok [HttpPost] public ActionResult ManualAttendence(HttpPostedFileBase file, AttendanceManualModels model) { int returnValue = 0; // Verify that the user selected a file if (file != null && file.ContentLength > 0) {