protected void Page_Load(object sender, EventArgs e) { DataTable dt= ReadExcelToTable("E:\\31october\\Excel\\Files\\empdata.xlsx"); }private DataTable ReadExcelToTable(string path) { //Connection String string connstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1';"; //the same name //string connstring = Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + path + //";Extended Properties='Excel 8.0;HDR=NO;IMEX=1';"; using(OleDbConnection conn = new OleDbConnection(connstring)) { conn.Open(); //Get All Sheets Name DataTable sheetsName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,new object[]{null,null,null,"Table"}); //Get the First Sheet Name string firstSheetName = sheetsName.Rows[0][2].ToString(); //Query String string sql = string.Format("SELECT * FROM [{0}]",firstSheetName); OleDbDataAdapter ada =new OleDbDataAdapter(sql,connstring); DataSet set = new DataSet(); ada.Fill(set); return set.Tables[0]; } }
Showing posts with label store in db. Show all posts
Showing posts with label store in db. Show all posts
Wednesday, August 14, 2013
How to read excel file data into datatable in c# to store in db
Subscribe to:
Posts (Atom)
can you please explain me Backpropagation & Gradients in layman language as simple as possible
Absolutely! Let’s break down backpropagation and gradients in the simplest possible way , like we’re teaching a curious 10-year-old. 🎯...
-
The error message you encountered ("DeleteService FAILED 1072: The specified service has been marked for deletion") indicates tha...
-
Transformers have shown promising results in various natural language processing (NLP) tasks, but they can also be adapted for time series ...
-
The error message you're seeing indicates that the "global using directive" feature is currently unsupported in the version o...