string extension = Path.GetExtension(FileUpload1.FileName); filename = DateTime.Now.ToString("dd-MM-yyyy") + "_" + DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + DateTime.Now.Millisecond + extension; FileUpload1.SaveAs(Server.MapPath("~/Account/PublishedRanklist/") + filename); string path = Server.MapPath("~/Account/PublishedRanklist/" + filename); OleDbConnection oconn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=Excel 8.0"); OleDbCommand ocmd = new OleDbCommand("select * from [Sheet1$]", oconn); oconn.Open(); OleDbDataReader odr = ocmd.ExecuteReader(); while (odr.Read()) { int Regno=valid(odr, 0); } oconn.Close();
protected string valid(OleDbDataReader myreader, int stval)//if any columns are found null then they are replaced by zero { object val = myreader[stval]; if (val != DBNull.Value) return val.ToString(); else return Convert.ToString(0); }
OleDbDataReader odr = ocmd.ExecuteReader();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)