Data Platform Developer Center > Data Platform Development Forums > ADO.NET Data Providers > DataReader.NextResult getting results from other simulataneous ExecuteReader calls
Ask a questionAsk a question
 

QuestionDataReader.NextResult getting results from other simulataneous ExecuteReader calls

  • Thursday, January 17, 2008 12:50 PMEarthwareMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello

    Heres the outline of the problem:

    A single asp.net page is calling our DAL in 2 different places to request data. One request is in the page itself and returns our search results, the other is in a custom control on the page.

    Both requests (one from the page one from the control) are using new instances of our DAL component, and the component itself creates new commands and connections. Both methods in the DAL use DataReader.NextResult to read multiple result sets back from the sprocs they call.

    What is happending, and only a few times a day for a busy site, is that one method is getting the result set destined for the other method, which is we assume being called at the same time.

    As I cannot replicate the error during debug we log the number of fields and their names when this error occurs and I can see the fields match exactly what should be comming back for the other method.

    Im not sure if this is an expected error, as both requests I guess are using the same thread. I can only assume if happens randomly because most of the time one method must finish before the other one is called and only sometimes when the first one takes longer to execute do their execution clash like this.

    Has anyone ever seen this before? I know we could just code it without the DataReader.NextResult but Im more worried what else this effects I have not found yet.

    Thanks
    Brian Norman
    www.earthware.co.uk

All Replies

  • Friday, November 06, 2009 5:51 PMrranly Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Having the same issue. Very odd, using SqlHelper.ExecuteReader and on occasion the wrong data is returned. It returns data from a different call.
  • Monday, November 09, 2009 11:17 AMVMazurMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Any static/shared methods involved into that part of code?
    Val Mazur (MVP) http://www.xporttools.net