简体   繁体   English

VB6应用程序可以连接到SQL Server,但.NET应用程序不能

[英]VB6 applications can connect to SQL Server, but .NET applications can't

Our system uses a combination of VB6 legacy applications and newer .NET applications. 我们的系统结合使用VB6遗留应用程序和较新的.NET应用程序。 The applications are deployed to our clients, and they run the applications from a Terminal Server box, with the SQL Server database running on a different box. 应用程序部署到我们的客户端,他们从终端服务器框运行应用程序,SQL Server数据库在不同的框上运行。

The VB6 applications work fine, while all of the .NET applications fail on startup (trying to connect to the database to read configuration information) every time with the error: VB6应用程序工作正常,而所有.NET应用程序在启动时都会失败(尝试连接到数据库以读取配置信息),每次都有错误:

System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. System.Data.SqlClient.SqlException:建立与SQL Server的连接时发生与网络相关或特定于实例的错误。 The server was not found or was not accessible. 服务器未找到或无法访问。 Verify that the instance name is correct and that SQL Server is configured to allow remote connections. 验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) (提供程序:TCP提供程序,错误:0 - 连接尝试失败,因为连接方在一段时间后没有正确响应,或者由于连接主机无法响应而建立连接失败。)

Here's the really weird thing: I created a test .NET application in C# that replicates the exact connection string used by the .NET applications -- I deployed an instrumented version of one of the applications that displays the actual connection string used -- and the test app works . 这是非常奇怪的事情:我在C#中创建了一个测试.NET应用程序,它复制了.NET应用程序使用的确切连接字符串 - 我部署了一个显示所使用的实际连接字符串的应用程序的检测版本 - 以及测试应用程序的工作原理

VB6 connection string (works): Provider=SQLOLEDB;Data Source=servername;Initial Catalog=databasename;User ID=username;Password=password; VB6连接字符串(有效): Provider=SQLOLEDB;Data Source=servername;Initial Catalog=databasename;User ID=username;Password=password;

.NET connection string (both works and doesn't work): Data Source=servername;Initial Catalog=databasename;User ID=username;Password=password;Application Name="ourappname" .NET连接字符串(两者都有效和不起作用): Data Source=servername;Initial Catalog=databasename;User ID=username;Password=password;Application Name="ourappname"

None of our other clients have experienced this issue with the same binaries, which tells me it's a problem with how the .NET applications are interacting with this particular client's system. 我们的其他客户都没有遇到过同一个二进制文件的问题,这告诉我.NET应用程序如何与这个特定客户端系统进行交互是一个问题。

What steps should I take to troubleshoot/fix this issue? 我应采取哪些步骤来解决/解决此问题? I'm really at a loss at this point. 我现在真的很茫然。 I'm hoping someone else has seen this issue before; 我希望其他人之前见过这个问题; I couldn't find anything relevant on Google. 我在Google上找不到任何相关内容。


  • Both boxes are Windows Server 2008 R2 SP1 running on VMWare, and are in the same domain 这两个框都是在VMWare上运行的Windows Server 2008 R2 SP1,并且位于同一个域中
  • Both boxes run ESET NOD32; 两个盒子都运行ESET NOD32; disabling didn't change anything 禁用没有改变任何东西
  • SQL Server is a default instance of 2008 R2 RTM (there are also 2008 and 2008 R2 named instances on the same box) SQL Server是2008 R2 RTM的默认实例(在同一个框中也有2008和2008 R2命名实例)
  • The applications (and my test app) are .NET 4.0 应用程序(和我的测试应用程序)是.NET 4.0
  • The application uses a SQL login to authenticate (yes, I checked that the password being used by the failing apps is correct) 该应用程序使用SQL登录进行身份验证(是的,我检查了失败的应用程序使用的密码是否正确)
  • Some of the .NET applications use different code to do application startup, yet they all exhibit the same error 某些.NET应用程序使用不同的代码来执行应用程序启动,但它们都表现出相同的错误
  • Some of the .NET applications are C#, some are VB, some are mixed (VB apps, C# core assemblies) 一些.NET应用程序是C#,一些是VB,一些是混合的(VB应用程序,C#核心程序集)
  • I've tried repairing the .NET 4.0 install 我试过修复.NET 4.0安装
  • I've tried rebooting both boxes 我试过重启两个盒子
  • I've tried deploying the source binaries such that our deployment subsystem was circumvented (in case it was causing corruption of some kind) 我已经尝试部署源二进制文件,以便绕过我们的部署子系统(如果它导致某种类型的损坏)
  • The instrumented application which I compiled locally experiences the same behaviour as the original, which was built via Team System 我在本地编译的检测应用程序经历了与通过Team System构建的原始应用程序相同的行为

I have found that there are usually a few primary causes of this behavior: 我发现这种行为通常有几个主要原因:

  1. SQL Server is not configured to listen for the specific connection type. SQL Server未配置为侦听特定连接类型。 To determine this, open SQL Server Configuration Manager on the SQL Machine, click the SQL Server Network COnfiguraiton and then Protocols for MSSQLServer. 要确定这一点,请在SQL计算机上打开SQL Server配置管理器,单击SQL Server网络COnfiguraiton,然后单击MSSQLServer的协议。 Verify that TCP/IP is enabled. 验证是否已启用TCP / IP。

  2. SQL Server not allowing remote connections (if other apps are connecting, then this is obviously not a problem). SQL Server不允许远程连接(如果其他应用程序正在连接,那么这显然不是问题)。

  3. The client machine is not configured to talk to SQL Server using SQL Server's supported protocols OR the the client machine has incorrect configuration information entered. 客户端计算机未配置为使用SQL Server支持的协议与SQL Server通信,或者客户端计算机输入的配置信息不正确。 To verify this, run cliconfg from the Run... prompt and ensure the appropriate protocols are enabled and that there aren't any conflicting aliases in the Alias tab. 要验证这一点,请从Run ...提示符运行cliconfg,并确保启用了相应的协议,并且Alias选项卡中没有任何冲突的别名。 I usually add one specifically for the machine name configured in the connection string with the appropriate IP address in case there is a DNS issue (at least for testing). 我通常会为连接字符串中配置的计算机名称添加一个特定的IP地址,以防出现DNS问题(至少用于测试)。

  4. Since VB6 clients work and .Net clients don't there could be an issue with 64-bit versus 32-bit access. 由于VB6客户端工作,而.Net客户端不工作,因此64位与32位访问可能存在问题。 If your app is compiled for 64-bit or Any CPU, you may try a 32-bit build to see if that resolves the access. 如果您的应用程序是针对64位或任何CPU编译的,您可以尝试使用32位构建来查看是否可以解析访问权限。 If so, then this is most likely a 64-bit SQL Client configuration issue. 如果是这样,那么这很可能是64位SQL客户端配置问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM