Do I have to Dispose the SQLiteCommand objects?

后端 未结 4 1883
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-18 08:33

How do I treat the SQLiteCommand object, do I have to call Dispose() after ExecuteScalar, ExecuteNonQuery

4条回答
  •  爱一瞬间的悲伤
    2021-01-18 09:00

    If it is disposable, dispose it if you will not use it again. The best would be, to use using

    using(SQLiteCommand cmd as new SQLiteCoammand())
    {
       ...
    }
    

    So it will be disposed automatically when leaving the using scope.

提交回复
热议问题