c# - I need a fast work-around for "There is already an open DataReader associated with this Command which must be closed first" -
I have the following class, which generates an error in the query title for the line msgHistory.Messages.Add ( Pd);
.
Public Zero Store Message (StringUserto, String Userframe, String Message) {In reference to var collection = pm. Select Private Mensheed pm; Foreign currency (var msgHistory in the collection) {string user1 = msgHistory.User1; String User 2 = msgHistory.User2; If ((user = 1 == user to end user 2 = userframe) || (user1 = userfom and user2 = uratoteo)) (private message delt pd = new management del.php.User = UserFrom; pd.message = Message; msgHistory.Messages.Add (PD); Context.Entry (msgHistory) .set = System.Data. Entity.EntityState.Modified; // Amendment returns saves;}}
Whatever I collect, the unit framework still has an open connection, but I do not understand why it does not allow me to modify ... I want to It is as fast as possible to execute and I am afraid that if I want to get the ID, close the loop with a break, and then search the privateMessageHeader
model, then I have more commands
Usually this message is based on the underlying code The reason which is looping on a result from the previous operation is when this tries to execute a SqlCommand Loop works in a situation using a SqlDataReader and this object is a unique use of the connection that can not be used to execute commands. (View)
Add a simple connection to your connection string
"MultipleActiveResultSets = True;"
This allows sharing of connections between SqlDataReader and SqlCommand
A more detailed description can be found
Comments
Post a Comment