且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

过程在 ADO.NET 中超时,但在 SSMS 中没有

更新时间:2023-02-07 08:26:56

您可以将超时会话的 SET 选项与未超时会话的 SET 选项进行比较:

You can compare the SET options for the session that is timing out to those from the session that is not:

SELECT
    session_id,
    [ansi_defaults],
    [ansi_null_dflt_on],
    [ansi_nulls],
    [ansi_padding],
    [ansi_warnings],
    [arithabort],
    [concat_null_yields_null],
    [deadlock_priority],
    [quoted_identifier],
    [transaction_isolation_level]
FROM
    sys.dm_exec_sessions
WHERE
    session_id IN (<spid1>, <spid2>);

当您发现一些不同时,尝试在 SSMS 查询中将每个设置更改为相反的设置,直到您获得超时(或在发送查询之前手动设置应用代码中的选项).现在,我手边没有 2005 实例,所以没有测试这个查询.您可能需要注释掉一个或多个列名.

When you find some that are different, experiment with changing each setting to the opposite in your SSMS query until you get the timeout (or manually setting the option(s) in your app code before sending the query). Now, I don't have a 2005 instance handy, so have not tested this query. You may need to comment out one or more column names.