Best practice for reusing SqlConnection

后端 未结 5 2032
误落风尘
误落风尘 2021-01-17 09:43

I\'ve come from Java experience and am trying to start with C#. I\'ve read SqlConnection SqlCommand SqlDataReader IDisposable and I can understand that the best practice to

5条回答
  •  醉话见心
    2021-01-17 10:28

    To answer your specific question, you can reuse a SqlConnection for each query. Just make sure to close your current query (SqlDataReader, etc.) before you run another one, ie. wrap them in their own using blocks.

提交回复
热议问题