取消项目后:未在本地计算机上注册"Microsoft.ACE.OLEDB.12.0"提供程序. [英] After Pulished project : The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

查看:97
本文介绍了取消项目后:未在本地计算机上注册"Microsoft.ACE.OLEDB.12.0"提供程序.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在我的项目中,从服务器读取excel文件.我的代码如下:

Hi,
In my project, reading excel file from server. my code is given below:

public DataTable ReadExcelToTable(string path, string extention, string useruid, out string message)
      {

          DataSet TotMaster = new DataSet();

          string strConn;
          //string strConn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + @";Extended Properties=""Excel 12.0 Xml;HDR=YES""";

          if (extention.Contains(".xlsx"))
          {
              strConn = "Provider=Microsoft.ACE.OLEDB.12.0;" +
                 "Data Source=" + path + "; Extended Properties=Excel 12.0;";
          }
          else
          {
              strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                  "Data Source=" + path + "; Extended Properties=Excel 8.0;";
          }

          OleDbConnection myData = new OleDbConnection(strConn);
          try
          {
              myData.Open();
          }
          catch (OleDbException e)
          {
              try
              {
                  strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + path + ";" + "Extended Properties=Excel 8.0;HDR=YES;";
                  myData = new OleDbConnection(strConn);
                  myData.Open();
              }
              catch (Exception e2)
              {
                  strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + @";Extended Properties=""HTML Import;HDR=YES;IMEX=1"";";
                  myData = new OleDbConnection(strConn);
                  myData.Open();
              }
          }

          int i = 1;
          try
          {
              if (myData.GetSchema("tables").Rows.Count > 0)
              {
                  foreach (DataRow row in myData.GetSchema("tables").Rows)
                  {
                      i++;
                      string name = row[2].ToString().Replace("''", "'").TrimEnd('_');
                      DataSet ds = new DataSet();
                      OleDbDataAdapter d = new OleDbDataAdapter("SELECT * from [" + name + "]", strConn);
                      d.Fill(ds);
                      if (ds.Tables[0].Rows.Count > 0)
                      {
                          DataTable dt = ds.Tables[0].Copy();
                          dt.Namespace = name;
                          TotMaster.Tables.Add(dt);
                      }
                  }
              }
          }
          catch (Exception ex)
          {
              ex.Message.ToString();
          }

          if (ValidateTotMasterExcel(TotMaster.Tables[0]))
          {
              message = "success";
          }
          else
          {
              message = "Your Tot Master excel file format is not correct.";
          }

          myData.GetSchema("tables").Dispose();
          myData.Close();
          return TotMaster.Tables[0];
      }




我正在使用vs2008.

在Windows Server 2008 R2 Enterprise上的iis上发布项目之后.
在服务器上,我们正在使用Office2007.

它的抛出错误是:




i am using vs 2008.

after publishing project on iis on window server 2008 r2 enterprise.
on server we are using office 2007.

its throw error is :

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.



请建议我解决此问题.

谢谢



Please suggest i solve this issue.

Thanks

推荐答案

似乎在此线程中得到了解决:
http://social.msdn.microsoft.com/论坛/nn-NO/exceldev/thread/0f03c2de-3ee2-475f-b6a2-f4efb97de302 [
It seems to be solved in this thread:
http://social.msdn.microsoft.com/Forums/nn-NO/exceldev/thread/0f03c2de-3ee2-475f-b6a2-f4efb97de302[^]


这篇关于取消项目后:未在本地计算机上注册"Microsoft.ACE.OLEDB.12.0"提供程序.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆