SqlDataAdapter.Fill() within a SqlTransaction - is this a bad practice?

前端 未结 2 584
有刺的猬
有刺的猬 2021-01-25 16:34

Since I have a \"DB util\" class with a DataSet QueryDB(string spName, DBInputParams inputParams) method which I use for all my calls to the database, I would like

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-25 17:18

    It is a bad practice because while the transaction is open, records/pages/tables that you make changes to are locked for the duration of the transaction. The fill just makes the whole process keep those resources locked longer. Depending on your sql settings, this could block other accesses to those resources.

    That said, if it is necessary, it is necessary, just realize the penalty for doing it.

提交回复
热议问题