当前位置: 代码迷 >> ASP.NET >> C#读取Excel The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the loc解决办法
  详细解决方案

C#读取Excel The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the loc解决办法

热度:8503   发布时间:2013-02-25 00:00:00.0
C#读取Excel The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the loc
在服务器调试的时候,读取Excel没有问题,但是一旦发布,就不行了。
报错:The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.
我觉得是不是应用池环境和 Visual Web Developer Web Server测试环境不同的问题?
我的环境是XP+Visual Studio 2005.
不知道该怎么设置IIS.

代码:
  DataSet ds = null;
  string strconn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + savefilepath + ";" + "Extended Properties='Excel 8.0;HDR=NO;IMEX=1;'";
  OleDbConnection conn = new OleDbConnection(strconn);
  try
  {
  conn.Open();
  OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Sheet1$]", strconn);
  ds = new DataSet();
  myCommand.Fill(ds, "[sheet1$]");
  EUCnameTextBox.Text = ds.Tables[0].Rows[6][1].ToString();

  }
  finally
  {

  conn.Close();
  }

------解决方案--------------------------------------------------------
使用ADo.NET读取不用安装Office

更不用设Excel权限

什么也打不开了,不管是不是导入excel的页面,都是server unavailable..应该是iis配置的问题。跟到数据就没关系;了

  相关解决方案