try { string excelConnectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=Yes'", path); connection = new OleDbConnection(); connection.ConnectionString = excelConnectionString; OleDbCommand command = new OleDbCommand("select * from [Sheet1$]", connection); connection.Open(); DbDataReader dr = command.ExecuteReader(); DataTable table = new DataTable("Customers"); table.Load(dr); table.Columns.Add("UploadedFromDate", typeof(DateTime)); table.Columns.Add("UploadedToDate", typeof(DateTime)); table.Columns.Add("CreatedDate", typeof(DateTime)); foreach (DataRow row in table.Rows) { row["UploadedFromDate"] = DateTime.ParseExact(txtfromdate.Text.Trim(), "yyyy-MM-dd HH:mm tt", null); row["UploadedToDate"] = DateTime.ParseExact(txttodate.Text.Trim(), "yyyy-MM-dd HH:mm tt", null); row["CreatedDate"] = System.DateTime.Now; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)