This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16965|Reply: 0

[ASP.NET] If you already have an open DataReader associated with this Command, you must first close it.

[Copy link]
Posted on 5/8/2015 12:55:35 PM | | | |

The above error occurs when two or multiple sqldatareaders are opened at the same time. Because sqldatareader is used to read database data, sqlconnection is on but not closed.

    I checked online and found that a SqlConnection can only execute a transaction once, and it must be closed and then opened again. I only used it once above and did not turn it off, and it turned on directly, so it will report an error. In fact, you don't have to open it multiple times, so it's very troublesome to implement. Just add MultipleActiveResultSets=true directly after the connection string. If there is a configuration file, you can modify the configuration file directly.






Previous:Batch detection of user input for SQL dangerous characters
Next:Based on. .LINQ to SQL three-layer architecture development
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com