A connection was successfully established with the server, but then an error occurred during the pre-login handshake. TCP provider, error: 0

自作多情 提交于 2020-01-16 02:54:08

问题


I always get the above error when trying to connect to a SQL server 2000 database hosted on a "server" with Windows XP pro. The client pc (my working environment) is Windows 7.

Up to now I have developed my application using Visual Studio 2010 and Net framework 4.0. All was working correctly. Then I have installed Visual Studio Express 2012 for Web and ASP.NET 4.5.

Now, when i try to connect via SqlConnection conConnection .Open() i get the Exception:

A connection was successfully established with the server, 
but then an error occurred during the pre-login handshake. 
(provider: TCP Provider, error: 0 - 
An existing connection was forcibly closed by the remote host.)

Please note the second message, because I have found very little info on that: An existing connection was forcibly closed by the remote host.

I have yet unsuccessfully tried a myriad solutions, including:

  • Various connection strings (Encrypt=false; )
  • netsh WinSock Show Catalog > winsocks.txt (don't seem to spot any strange application here)
  • netsh Winsock reset on both client and server
  • Rebuilding the app from Visual Studio targeting Net 4.0 / Net 4.5
  • Use Visual Studio Development Server or Local IIS Web Server
  • IIS reset, restarting Client and Server pc variuos times
  • Checked the SQL Server 2000 properties, connections, logs, profiler...

What other could I try next without disinstalling Net 4.5 (and Visual Studio 2012)?


Important additional info

This same application is deployed in a production server (Windows 7, IIS 7.5, Net framework 4.0). The application actually in production was compiled with Visual Studio 2010, net 4.0, and is connecting correctly with no errors (thankfully)! So, the problem has arisen on my client machine after I have installed VS Express 2012 and Asp.net 4.5. (I have also tried to open and recompile the solution with VS2010, but I get the same exception).


EDIT

For testing purpose, I have deployed my application, compiled with VS 2012 / Net 4.0, to the "production" server (on which I have never installed Net 4.5 of course). For this I have created a new Web Site, with Application pool set to Integrated pipeline and targeting Net Framework v4.0.30319. Now, this test web site connect successfully to my test SQL Server database (SQL 2000) and also to my production server database (SQL7). Clue:

the problem resides only on my client pc, and the culprit is Net 4.5?


EDIT 2

Connecting via Visual Studio 2010 or 2012 Server Explorer, Data Source: Microsoft SQL Server (SqlClient) gives the same Exception (only difference is that now is pre-login handshake timeout).

Instead Connecting from Microsoft SQL Server Management Studio 2008 works fine! (Server type: Database engine; Server name: myserver\SQL2000; Authentication: SQL Server Auth; Login: Password)

How can be that the connection from SQL Server Management Studio works fine?


回答1:


Did you uninstall VS 2012 to "fix" this issue? Why can't you install .NET 4.5 on the server or copy the DLLs to the server per Marc Gravell's post at http://marcgravell.blogspot.co.nz/2012/09/iterator-blocks-missing-methods-and-net.html?




回答2:


I am essentially having the same problem. ASP.NET Project that runs successfully on a Win 7 computer in visual studio 2010 but moved to a Windows 8 box running Visual Studio 2012. Project is converted by VS when running it throws the SQL server error message described above. SQL server is remote but both clients (Win 7 and Win 8) are local on the same network. One works and the other doesn't.

Comparing setup on both machines in IIS I found that there is a difference between the configuration of the Application Pool in use by the web application. The Identity property defaults to "ApplicationPoolIdentity" but if you change it to "NetworkService" then the problem is resolved. Hopefully this will help someone else as I have done an extensive search and found nothing that pointed to this.



来源:https://stackoverflow.com/questions/16911681/a-connection-was-successfully-established-with-the-server-but-then-an-error-occ

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!