C# winform程序。
有三台机器,同时运行同样的程序,用同一用户连接数据库。
功能都能完成,连接,查数据,修改什么的。
但是经常报告错误:
有几个主要错误
System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - 远程主机强迫关闭了一个现有的连接。)
System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to 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. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
System.Data.SqlClient.SqlException: The client was unable to establish a connection because of an error during connection initialization process before login. Possible causes include the following: the client tried to connect to an unsupported version of SQL Server; the server was too busy to accept new connections; or there was a resource limitation (insufficient memory or maximum allowed connections) on the server. (provider: Named Pipes Provider, error: 0 - 管道的另一端上无任何进程。)
System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - 远程主机强迫关闭了一个现有的连接。)
不知道是程序问题,还是程序配置问题,还是服务器配置问题,
请指教
------解决方案--------------------
可能网络不稳定
程序应该用短连接,即每次提交数据都建立连接、提交、关闭连接。
------解决方案--------------------
程序连接的话要开启Named Pipes这个协议,一般经常要用到这个协议
其他错误感觉像是网络问题呵呵
------解决方案--------------------
这个还不知道啥原因哦
------解决方案--------------------
你可以尝试一下使用TCP:SERVERNAME,PORTNUMBER 强制TCP连接看看会不会有问题。
另外你出问题的时候,服务器负载如何?CPU利用率?网络?
------解决方案--------------------
出问题的时候你可以TELNET 262.18.17.34, 1433? ping有没有延迟?
如果TELNET么有问题,可以尝试抓一个NETWORK TRACE。