saravanan m

saravanan m

  • NA
  • 9
  • 0

Need to read data from Microsoft Excel using asp.net with c#

Feb 17 2006 8:53 AM
Hi, I need to extract a column from a Excel using Asp.Net and C#. That column datas to be used as an input for a particular task.. I have pasted the codings... Please help me... If i execute the project, only column name is displayed... Code: private void mymethod() { try { string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source="+ Server.MapPath("Dnb_Pro.xls")+";"+ "Extended Properties=Excel 8.0;"; OleDbConnection objConn = new OleDbConnection(sConnectionString); objConn.Open (); OleDbCommand objCmdSelect = new OleDbCommand("Select * from Phone_Number",objConn); OleDbDataAdapter objAdapter1 = new OleDbDataAdapter(); objAdapter1.SelectCommand = objCmdSelect; DataSet objDataSet1 = new DataSet(); objAdapter1.Fill(objDataSet1); DataGrid1.DataSource = objDataSet1.Tables[0].DefaultView; DataGrid1.DataBind(); objConn.Close(); } catch(OleDbException ex) { throw ex; } } Pls do reply soon Regards, Saravanan.M