Microsoft OLE DB Provider for SQL Server 错误“80004005”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15126625/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Microsoft OLE DB Provider for SQL Server error '80004005'
提问by Burt
I have migrated a classic ASP site to a new server and am getting the following error, message.
我已将经典 ASP 站点迁移到新服务器,但收到以下错误消息。
I have tried different connection strings but none of them work.
我尝试了不同的连接字符串,但它们都不起作用。
I am not even sure if the connection string is the problem
我什至不确定连接字符串是否有问题
The new server is a Windows 2012 Server, SQL Server 2008 R2 Express machine.
新服务器是一台 Windows 2012 Server、SQL Server 2008 R2 Express 机器。
Microsoft OLE DB Provider for SQL Server error '80004005'
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
/scripts/dbcode.asp, line 31
Application("C2M_ConnectionString") = "Provider=SQLNCLI10;Server=(local);Database=mysite_live;Uid=mysitec_Live;Pwd=mypass;"
回答by Aaron Bertrand
If it is an Express instance, it is most likely not a default instance, but rather a named instance. So you probably meant:
如果它是一个 Express 实例,它很可能不是一个默认实例,而是一个命名实例。所以你可能的意思是:
... "Provider=SQLNCLI10;Server=.\SQLEXPRESS; ...
--- instead of just (local) ---^^^^^^^^^^^^
Otherwise you'll need to show us the server properties in SQL Server Configuration Manager on that machine in order for us to be able to tell you how to correct your connection string.
否则,您需要在该计算机上的 SQL Server 配置管理器中向我们显示服务器属性,以便我们能够告诉您如何更正连接字符串。
回答by Raymond A
As Aaron Bertrand mentioned it would be interesting to have a look at your connection properties (In Sql Server configuration check if the following are enabled Name Pipes and TCP/Ip). Since you're able to connect from SSMS i would ask to check if the Remote connection is allowed on that server Also can you tell is the Sql browser service is running?
正如 Aaron Bertrand 提到的,查看您的连接属性会很有趣(在 Sql Server 配置中检查是否启用了名称管道和 TCP/Ip)。由于您可以从 SSMS 连接,我会要求检查该服务器上是否允许远程连接您还可以判断 Sql 浏览器服务是否正在运行?
here is a link that i keep close to me as a reminder or check list on probable connection issues on SQL Server. Sql Connection IssuesAnd lastly can you try as provider "SQLNCLI" instead of "SQLNCLI10"
这是我放在身边的一个链接,作为 SQL Server 上可能的连接问题的提醒或检查列表。 Sql 连接问题最后你可以尝试作为提供者“SQLNCLI”而不是“SQLNCLI10”
回答by Mike C.
Here is what I would do:
这是我会做的:
EDIT: Note that this SO post, a few down, has an interesting method for creating the correct connection string to use.
编辑:请注意,此 SO post有一些有趣的方法来创建要使用的正确连接字符串。
- Open SSMS (Sql Server Management Studio) and copy/paste the username/password. Don't type them, copy/paste. Verify there isn't an issue.
- Fire up the code (this is next for me b/c this would be the next easiest thing to do in my case) and step to line 31 to verify that everything is setup properly. Here is some infoon how to do this. I understand that this may be impossible for you with this being on production so you might skip this step. If at all possible though, I'd set this up on my local machine and verify that there is no issue connecting locally. If I get this error locally, then I have a better chance at fixing it.
- Verify that Provider=SQLNCLI10 is installed on the production server. I would follow this SO post, probably the answer posted by gbn.
- You have other working websites? Are any of them classic asp? Even if not, I'd compare the connection string in another site to the one that you are using here. Make sure there are no obvious differences.
- Fire up SQL Server Profiler and start tracing. Connect to the site and cause the error then go to profiler and see if it gives you an additional error information.
- If all of that fails, I would start going through this.
- 打开 SSMS(Sql Server Management Studio)并复制/粘贴用户名/密码。不要输入它们,复制/粘贴。确认没有问题。
- 启动代码(这对我来说是下一个 b/c 这将是我的下一个最容易做的事情)并转到第 31 行以验证一切设置是否正确。以下是有关如何执行此操作的一些信息。我知道这对你来说可能是不可能的,因为它正在生产中,所以你可以跳过这一步。如果可能的话,我会在我的本地机器上设置它并验证本地连接没有问题。如果我在本地遇到此错误,那么我就有更好的机会修复它。
- 验证 Provider=SQLNCLI10 是否安装在生产服务器上。我会关注这个 SO post,可能是 gbn 发布的答案。
- 你有其他工作网站吗?它们中的任何一个都是经典的asp吗?即使没有,我也会将另一个站点中的连接字符串与您在此处使用的连接字符串进行比较。确保没有明显的差异。
- 启动 SQL Server Profiler 并开始跟踪。连接到该站点并导致错误,然后转到分析器并查看它是否为您提供了其他错误信息。
- 如果所有这些都失败了,我会开始经历这个。
Sorry I can't just point to something and say, there's the problem!
抱歉,我不能只是指着某件事说,这就是问题所在!
Good luck!
祝你好运!
回答by egrunin
In line 31:
在第 31 行:
cmd.ActiveConnection = Application("C2M_ConnectionString")
How are you instantiating cmd
?
你是如何实例化的cmd
?
Rather than the ConnectionString being wrong, maybe cmd
is acting differently in the new environment.
而不是 ConnectionString 错误,可能cmd
在新环境中表现不同。
Edited to add:
编辑添加:
I see that you've gone from IIS 7 to IIS 8. To run Classic ASP sites on IIS 7 required manual changes to server defaults, such as "allow parent paths." Is it possible that some of the needed tweaks didn't get migrated over?
我看到您已经从 IIS 7 转到了 IIS 8。要在 IIS 7 上运行经典 ASP 站点,需要手动更改服务器默认值,例如“允许父路径”。是否有可能一些需要的调整没有被迁移?
If you're not running with Option Strict On, you should try that - it often reveals the source of subtle problems like this. (Of course, first you'll be forced to declare all your variables, which is verytedious with finished code.)
如果您没有使用 Option Strict On 运行,您应该尝试这样做 - 它通常会揭示像这样的微妙问题的根源。(当然,首先您将被迫声明所有变量,这对于完成的代码来说非常乏味。)
回答by Slava
Have you ever tried SQL Server OLE DB driver connection string:
您是否尝试过 SQL Server OLE DB 驱动程序连接字符串:
"Provider=sqloledb;Data Source=(local);Initial Catalog=mysite_live;User Id=mysitec_Live;Password=mypass;"
or ODBC driver:
或 ODBC 驱动程序:
"Driver={SQL Server};Server=SERVERNAME;Trusted_Connection=no;Database=mysite_live;Uid=mysitec_Live;Pwd=mypass;"
At least this is what I would do if nothing helps. Maybe you will be able to get more useful error information.
如果没有任何帮助,至少这是我会做的。也许您将能够获得更多有用的错误信息。
回答by AardVark71
Could this be a x86/x64 thing?
这可能是 x86/x64 的东西吗?
The following thread seems to indicate that the (local)alias is a 32-bit alias which fails on 64-bit server: http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/c701d510-90e5-4dd0-b14f-ca1d694d6615(note that the error is exacly what you had)
以下线程似乎表明(本地)别名是在 64 位服务器上失败的 32 位别名:http: //social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/c701d510- 90e5-4dd0-b14f-ca1d694d6615(请注意,错误正是您所拥有的)
When you were testing the .udl on the server did you test both x86 and x64?
当您在服务器上测试 .udl 时,您是否同时测试了 x86 和 x64?
Following the advice from this blogpost (http://blogs.msdn.com/b/farukcelik/archive/2007/12/31/udl-test-on-a-64-bit-machine.aspx) you could test your local udl :
按照这篇博文(http://blogs.msdn.com/b/farukcelik/archive/2007/12/31/udl-test-on-a-64-bit-machine.aspx)的建议,您可以测试您的本地用户名:
- in 64-bit by just double clicking it (acts the same as running "C:\Program Files\Common Files\System\Ole DB\oledb32.dll",OpenDSLFile C:\\test.udl
- in 32-bit by double running C:\Windows\syswow64\rundll32.exe "C:\Program Files (x86)\Common Files\System\Ole DB\oledb32.dll",OpenDSLFile C:\\test.udl
- 在 64 位中,只需双击它(与运行“C:\Program Files\Common Files\System\Ole DB\oledb32.dll”相同,OpenDSLFile C:\\test.udl
- 在 32 位中通过双重运行 C:\Windows\syswow64\rundll32.exe "C:\Program Files (x86)\Common Files\System\Ole DB\oledb32.dll",OpenDSLFile C:\\test.udl
If you can confirm it's a problem with the alias I'd suggest you create a new one by following the guidelines found here: http://msdn.microsoft.com/en-us/library/ms190445(v=sql.105).aspx
如果您可以确认别名有问题,我建议您按照此处找到的指南创建一个新别名:http: //msdn.microsoft.com/en-us/library/ms190445(v=sql.105) .aspx
回答by Max
Have you tried to use the server IPaddress instead of the "(local)"? Something like "Server=192.168.1.1;" (clearly you need to use the real IP address of your server)
您是否尝试使用服务器 IP地址而不是“(本地)”?类似于“ Server=192.168.1.1;”(显然您需要使用服务器的真实IP地址)
In case you try to use the server IP address, check in the "SQL-Server configurator" that SQL Server is listeningon the IP address you use in your connection. (SQL Server Configurator screenshot)
如果您尝试使用服务器 IP 地址,请在“ SQL-Server 配置器”中检查SQL Server 正在侦听您在连接中使用的 IP 地址。(SQL Server 配置器截图)
Other useful thing to check / try:
检查/尝试的其他有用的东西:
- And check also if the DB is in the default SQL Server instance, or if it is in a named instance.
- Do you have checked if the firewall have the TCP/IP rule for opening the port of you SQL Server?
- Have you tried to connect to SQL Server using other software that use the TCP/IP connection?
- 并检查数据库是否在默认 SQL Server 实例中,或者它是否在命名实例中。
- 您是否检查过防火墙是否有打开 SQL Server 端口的 TCP/IP 规则?
- 您是否尝试过使用其他使用 TCP/IP 连接的软件连接到 SQL Server ?
回答by Paul Keister
The SQL Server Browser service is disabled by default on installation. I'd recommend that you enable and start it. For more information, see this linkand the section titled "Using SQL Server Browser" for an explanation of why this might be your problem.
默认情况下,安装时禁用 SQL Server Browser 服务。我建议您启用并启动它。有关详细信息,请参阅此链接和标题为“使用 SQL Server 浏览器”的部分,以解释为什么这可能是您的问题。
If you don't wish to enable the service, you can enable TCP/IP protocol (it's disabled by default), specify a static port number, and use 127.0.01,<port number> to identify the server.
如果您不想启用该服务,您可以启用 TCP/IP 协议(默认情况下是禁用的),指定一个静态端口号,并使用 127.0.01,<端口号> 来标识服务器。
回答by BALAJE
Step-1: Enabling TCP/IP Protocol Start >> All Programs >> Microsoft SQL Server >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server Network Configuration >> Protocols for MSSQLSERVER >> right click “TCP/IP” and select “Enable”.
步骤 1:启用 TCP/IP 协议 开始 >> 所有程序 >> Microsoft SQL Server >> 配置工具 >> SQL Server 配置管理器 >> SQL Server 网络配置 >> MSSQLSERVER 协议 >> 右键单击“TCP/IP”并选择“启用”。
Step-2: change specific machine name in Data Source attributes'value to (local) will resovle the problem ni SQL SERVER 2012.
步骤 2:将数据源属性值中的特定机器名称更改为(本地)将解决 SQL SERVER 2012 的问题。
回答by Ross Bush
Try pinging the server in your connection string. The server your application resides on should be able to communicate on the port you specify by credentials. If you are developing locally try specifying "localhost". If the server is clustered or you installed as an instance then you need to specify that instance. Also make sure the server is configured for mixed-mode authentication if using sql credentials.
尝试在您的连接字符串中 ping 服务器。您的应用程序所在的服务器应该能够在您通过凭据指定的端口上进行通信。如果您在本地开发,请尝试指定“localhost”。如果服务器是集群的或者您作为实例安装,那么您需要指定该实例。如果使用 sql 凭据,还要确保将服务器配置为混合模式身份验证。
OR Try
或尝试
Data Source=localhost;Initial Catalog=DBNAME;Persist Security Info=True;User ID=MyUserName; Password=MyPassword;
Data Source=localhost;Initial Catalog=DBNAME;Persist Security Info=True;User ID=MyUserName; 密码=我的密码;