Does End Using close an open SQL Connection

前端 未结 6 1514
礼貌的吻别
礼貌的吻别 2020-11-29 05:53

If I wrap a SQLConnection in a Using, should I close it or does the end using handle it?

using cn as new system.data.sqlclient.sqlconnection()
    cn.open
           


        
6条回答
  •  猫巷女王i
    2020-11-29 06:07

    According to MSDN you don't need the close statement.

    "The following example creates a SqlConnection, opens it, displays some of its properties. The connection is automatically closed at the end of the using block." -- http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.close.aspx

提交回复
热议问题