Joa*_*rel 6 .net sql numbers sqlexception
我SqlException在.NET 3.5应用程序的日志中得到一个,我正在寻找相应的数字(属性的值SqlException.Number).
System.Data.SqlClient.SqlException: A transport-level error has occurred
when receiving results from the server. (provider: TCP Provider, error: 0
- The specified network name is no longer available.) at
System.Data.SqlClient.SqlConnection.OnError
Run Code Online (Sandbox Code Playgroud)
我也得到错误,例如:
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.
Run Code Online (Sandbox Code Playgroud)
有谁知道如何正确捕捉这些例外?(你也可以在这里发表你的答案)
该特定错误不是来自SQL Server中的sys.messages - 因为它是连接的问题.所以我没有手数.
TBH,你应该做的最好的事情是确保将Number写入日志,但有例外 - 这样,你将始终在日志中并排显示数字和消息.可能无法回答你当前的问题,但这将是最好的前进恕我直言.不仅SqlException.Number但是SqlException.ErrorCode太-在这样的情况下,我觉得.ErrorCode可能是你的实际需要(不检查不知道)之一.
| 归档时间: |
|
| 查看次数: |
8031 次 |
| 最近记录: |