Problem opening oledb connection to excel file

B

Bill Youngman

I am trying to open an excel file on my local machine and read it's contents using the OleDbConnection class in C#.

Here is what I am doing--

string csv_store_read = "import/" + filename; --> points to excel file

string conn_excel_str;

OleDbConnection obj_oledb_con;

conn_excel_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath(".//" + csv_store_read) + ";Extended Properties=\"Excel 8.0;HDR=Yes;\"";

obj_oledb_con = new OleDbConnection(conn_excel_str);

obj_oledb_con.Open();

When I run this code my app throws an oledbexception error code -2147467259 (unspecified error)



I am developing with VS 2003 trying to connect to an Excel 2003 file and running .Net v1.1.4322.

Note: I do have VS 2005 w/ .Net v2.0.50727 installed on my machine but am not using this platform to develop the above application - it is strictly a .Net 1.1 app.

What am I missing or doing wrong?

TIA,

Bill Youngman
 
G

Guest

Are using excel (.xls) file or standard comma delimited file (.cvs) file?
There is a slight difference between those two formats.
Waiting your reply...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top