SqlCommand.Cancel() causes a performance boost?

前端 未结 4 781
感情败类
感情败类 2021-02-08 02:21

I have seen this show up several places in code, never with an explanation, just a cryptic comment above it (Declaration and execution included for an idea of context. It\'s jus

4条回答
  •  滥情空心
    2021-02-08 02:38

    According to MSDN, this is correct.

    The Close method fills in the values for output parameters, return values and RecordsAffected, increasing the time that it takes to close a SqlDataReader that was used to process a large or complex query. When the return values and the number of records affected by a query are not significant, the time that it takes to close the SqlDataReader can be reduced by calling the Cancel method of the associated SqlCommand object before calling the Close method.

    Weird!

提交回复
热议问题