尝试从Excel连接到SQL Server数据库时出错 [英] Error when trying to connect to SQL Server Database from Excel

查看:361
本文介绍了尝试从Excel连接到SQL Server数据库时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从Excel创建与SQL Server数据库的连接时收到此错误。我在网上找到了一个提到这个论坛的参考资料,但如果这不正确,请转发我。


详细信息:"从提供商处读取数据时发生错误: '无法加载文件或程序集'System.EnterpriseServices,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一。未提供所需的
模拟级别,或者提供的模拟级别无效。 (HRESULT异常:0x80070542)'"


我在尝试使用Power BI Desktop时遇到此错误,但在重置PC后我终于能够连接了。我仍然看到Excel的错误。如果我以管理员身份运行Excel,我可以连接到数据库,但这在我的环境中不实用


有关如何解决此问题的任何想法?


Michael


解决方案

嗨迈克尔,


欢迎来到MSDN论坛。


现在,如果您使用Power BI桌面(请登录正常帐户而不是管理员)连接SQL Server数据库,此错误是否仍然存在?


根据错误消息,一些社区成员通过启动管理员和e解决建立连接,所需的DLL正确注册
。之后,将其作为普通帐户启动也可以正常工作。


如果上述方法不起作用,请尝试以下方法:


  1. 请  修复   您的
    .NET Framework,重新启动服务器并再次尝试查看它是否有效。
  2. 检查文件夹:C:\ Windows \ Microsoftoft.NET\assembly\GAC_32 \ System.Enterpr iseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a,如果为空,请将这两个dll:System.EnterpriseServices.dll /
    System.EnterpriseServices.Wrapper.dll复制到此文件夹中。如果没有,请再次注册这些dll
  3. 打开CMD并运行命令:sfc / scannow扫描系统文件并修复一些已损坏或丢失的文件



祝你好运,


Sara


I am getting this error when I try to create a connection to a SQL Server database from Excel. I found a reference online that mentioned this Forum but please redirect me if this is incorrect.

Details: "An error happened while reading data from the provider: 'Could not load file or assembly 'System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Either a required impersonation level was not provided, or the provided impersonation level is invalid. (Exception from HRESULT: 0x80070542)'"

I previously got this error when trying to use Power BI Desktop, but after resetting my PC I was finally able to connect. I'm still seeing the error with Excel. If I run Excel as an Administrator, I can connect to the database, but that is not practical in my environment.

Any ideas on how to fix this?

Michael

解决方案

Hi Michael,

Welcome to the MSDN forum.

Now if you use the Power BI desktop (sign in with the normal account not the Administrator) to connect the SQL Server Database, does this error persists or not?

According to the error message, some community members solved by launching as an administrator and establishing the connection, the required DLLs are registered properly. After that, launching it as a normal account also works fine.

If the above method not works, please have a try with the following:

  1. Please repair your .NET Framework, restart your server and try again to see if it works.
  2. Check the folder: C:\Windows\Microsoft.NET\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a, if it is empty, copy these two dlls: System.EnterpriseServices.dll/ System.EnterpriseServices.Wrapper.dll into this folder. If not, register those dlls again
  3. Open the CMD and run the command: sfc /scannow to scan the system file and fix some corrupted or missing file once it found

Best regards,

Sara


这篇关于尝试从Excel连接到SQL Server数据库时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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