ConnectionString For Getting An Excel File Problem

点点圈 提交于 2019-11-29 17:23:39

The machine you're hosting the file on doesn't have the ACE OleDB for office driver installed. I would switch to the JetOleDB driver

A Jet OleDB connection string looks like

Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";

Excel8.0 is version 2003 I believe. For 2007 you will want to use Excel12.0

So what I would so is to do a String.Format and simply pass in the location of the excel file, of course since this appears to be an asp.net application it should look something like this:

String con = String.Format( @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties="Excel 8.0;HDR=Yes;IMEX=1"", Server.MapPath(EXCEL FILE LOCATION) );

You can of course simply put the String used in the String.Format in your config file that way it isn't hard coded like I have it.

Have a look at the following url, it has information on how to resolve this problem

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!