ado.net Closing Connection when using “using” statement

后端 未结 7 726
青春惊慌失措
青春惊慌失措 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:01

    when the scope

    using (SqlConnection con = new SqlConnection(//connection string) 
    {
    }
    

    will over , connection will automatically be disposed by runtime. so don't worry

提交回复
热议问题