ado.net Closing Connection when using “using” statement

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

    Using keyword will automatically close the connection for you so you don't need to worry about calling connection.close() at the end every time.

    0 讨论(0)
提交回复
热议问题