connection string reading data from excel in asp.net

Posted by Greg on Stack Overflow See other posts from Stack Overflow or by Greg
Published on 2010-05-18T07:01:59Z Indexed on 2010/05/18 14:00 UTC
Read the original article Hit count: 278

Hello,

I am trying to read data from excel file in asp.net. I have added the connection string to webConfig file:

<add name="xls" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=HPM_DB.xls;Extended Properties=Excel 8.0"/>

But it shows me an errormessage when I run this query:

string query = "Select * from [IO_Definition$]";

IO_Definition is the name of the spreadsheet in my excel file. I also added the excel file to the App_Data folder of the website.

The error is:

The Microsoft Jet database engine could not find the object 'IO_Definition$'. Make sure the object exists and that you spell its name and the path name correctly.

The thing is, when I write the absolute path of the excel file in the connectionString it does work. Is there anyway I can make it work without writing the absolute path?

Thanks,

Greg

© Stack Overflow or respective owner

Related posts about excel

Related posts about ASP.NET