ado.net Closing Connection when using “using” statement

后端 未结 7 686
青春惊慌失措
青春惊慌失措 2020-11-27 07:46

I am doing my database access methods to SQL Server like this

  using (SqlConnection con = new SqlConnection(//connection string)
  {
    using (SqlCommand c         


        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 08:02

    I think "using" was not required for SqlCommand. "Using" for SqlConnection would have done the job for you alone. In fact you connection is submitted to Connection pool.

提交回复
热议问题