执行SqlDataReader.Read之后,如果还想用另一个SqlCommand执行Insert或者Update操作的话,会得到一个错误提示:There is already an open DataReader associated with this Command which must be closed first.
解决方法是在ConnectionString中加上一个参数“MultipleActiveResultSets”, 将其值设置为true。
本文介绍了解决在使用SqlDataReader后尝试执行其他SqlCommand操作时出现的错误的方法。通过在ConnectionString中添加参数“MultipleActiveResultSets”并设置其值为true,可以避免错误的发生。
开发板推荐:天空星STM32F407VET6开发板
超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印
执行SqlDataReader.Read之后,如果还想用另一个SqlCommand执行Insert或者Update操作的话,会得到一个错误提示:There is already an open DataReader associated with this Command which must be closed first.
解决方法是在ConnectionString中加上一个参数“MultipleActiveResultSets”, 将其值设置为true。
开发板推荐:天空星STM32F407VET6开发板
超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印
5389
3万+
677
2211
539
390

被折叠的 条评论
为什么被折叠?
