I read an article on the link:
http://support.microsoft.com/default...b;en-us;306572 related to
reading data from Excel using OLEDB The topic's heading is: How to query and
display excel data by using ASP.NET, ADO.NET, and Visual C# .NET
I am trying with the same code in Visual Studio 2005 in ASP.NET application.
The code i am using is:
protected void Page_Load(objec t sender, EventArgs e)
{
String connectionStrin g =@"Provider=Mic rosoft.Jet.OLED B.4.0;Data
Source=C:\Inetp ub\wwwroot\Exce lData.xls;Exten ded Properties=Exce l 8.0;";
OleDbConnection con = new OleDbConnection (connectionStri ng);
con.Open();
OleDbCommand cmd = new OleDbCommand("S ELECT * FROM myrange1", con);
OleDbDataAdapte r da = new OleDbDataAdapte r();
da.SelectComman d = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "XLData");
//da.Fill(ds, "ExcelData" );
GridView1.DataS ource = ds.Tables[0].DefaultView;
//GridView1.DataS ource = ds;
GridView1.DataB ind();
con.Close();
}
I have included name space:using System.Data.Ole Db;
The problem is when i execute the application following exception is coming:
The Microsoft Jet database engine could not find the object 'myrange1'.
Make sure the object exists and that you spell its name and the path name
correctly.
I have followed the same steps while creating Excel file and have given the
same names but still having the problem Please help..