SqlConnection.ClientConnectionId 屬性

定義

最近連線的連線 ID,無論連線是否成功。The connection ID of the most recent connection attempt, regardless of whether the attempt succeeded or failed.

public:
 property Guid ClientConnectionId { Guid get(); };
public Guid ClientConnectionId { get; }
member this.ClientConnectionId : Guid
Public ReadOnly Property ClientConnectionId As Guid

屬性值

最近連線的連線 ID。The connection ID of the most recent connection attempt.

備註

無論您連接的伺服器版本為何,ClientConnectionId 都可以運作,但連線通道緩衝區錯誤的擴充事件記錄和專案將不會出現在 SQL Server 2008 R2SQL Server 2008 R2 和更早版本中。ClientConnectionId works regardless of which version of the server you connect to, but extended events logs and entry on connectivity ring buffer errors will not be present in SQL Server 2008 R2SQL Server 2008 R2 and earlier.

如果記錄連接識別碼的擴充事件已啟用,您就可以在擴充事件記錄檔中找出連接識別碼,以便查看失敗是否位於伺服器。You can locate the connection ID in the extended events log to see if the failure was on the server if the extended event for logging connection ID is enabled. 此外,您也可以針對特定連線錯誤,在連線信號緩衝區中找出連線識別碼 (透過連線信號緩衝區針對 SQL Server 2008 中的連線問題進行疑難排解)。You can also locate the connection ID in the connection ring buffer (Connectivity troubleshooting in SQL Server 2008 with the Connectivity Ring Buffer) for certain connection errors. 如果連接識別碼不在連接信號緩衝區中,您就可以假設發生網路錯誤。If the connection ID is not in the connection ring buffer, you can assume a network error.

適用於

另請參閱