There is already an open DataReader associated with this Command which must be closed first的錯誤解決辦法

執行SqlDataReader.Read之後,如果還想用另一個SqlCommand執行Insert或者Update操作的話,會得到一個錯誤提示:There is already an open DataReader associated with this Command which must be closed first.


解決方法是在ConnectionString中加上一個參數“MultipleActiveResultSets”, 將其值設置爲true。

 

 

發佈了33 篇原創文章 · 獲贊 1 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章