Does End Using close an open SQL Connection

前端 未结 6 1507
礼貌的吻别
礼貌的吻别 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条回答
  •  春和景丽
    2020-11-29 06:20

    Exiting a using block calls .Dispose() on the object in question (cn in your example) which for a SqlConnection will close the connection and any open resources.

提交回复
热议问题