Datareader associated with this command already opened must be disabled first

Source: Internet
Author: User

Error: A datareader associated with this command has been opened. You must first disable it.

Original code:

Public void updatepermissionusertypebyrightid (INT rightid, string usertypes) {var targetlist = listall (). where (S => S. rightid = rightid); foreach (VAR item in targetlist) {item. permissionusertype = usertypes; // Note: if the child node is visible, the parent node must be visible. // modify the permissions of the parent node. If a parent node exists, make sure that the role ID in the parent node is repeated if (item. parentid> 0) {menunodes parent1 = getbyid (item. parentid); string temppusertypes = jimshared. getnooverlapstr (item. permiss Ionusertype, parent1.permissionusertype); parent1.permissionusertype = temppusertypes ;}}//! Submit data commit ();}

After modification: (only a tolist () is added ())

Public void updatepermissionusertypebyrightid (INT rightid, string usertypes) {var targetlist = listall (). where (S => S. rightid = rightid ). tolist (); foreach (VAR item in targetlist) {item. permissionusertype = usertypes; // Note: if the child node is visible, the parent node must be visible. // modify the permissions of the parent node. If a parent node exists, make sure that the role ID in the parent node is repeated if (item. parentid> 0) {menunodes parent1 = getbyid (item. parentid); string temppusertypes = jimshared. getnooverlapstr (ITE M. permissionusertype, parent1.permissionusertype); parent1.permissionusertype = temppusertypes ;}}//! Submit data commit ();}

 

Datareader associated with this command already opened must be disabled first

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.