首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-09-23 
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
在服务器调试的时候,读取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配置的问题。跟到数据就没关系;了

热点排行