|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Multiple active readers on one connection?Hi;
For a single DbConnection, can I call DbCommand.ExecuteReader() for several selects and then for each reader call Read() and iterate through the rows. I have a situation where for my outer reader, for each row I need to call a select and iterate through the inner list of rows. -- thanks - dave ..NET 1.1 / SQL2K world - No you can't.
There is a new and shiny thing called MARS - but I would highly recommend understanding it's implications before you start doing it. - Sahil Malik [MVP] ADO.NET 2.0 book - http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx ---------------------------------------------------------------------------- Show quote "David Thielen" <thielen@nospam.nospam> wrote in message news:3088DDC3-C6B0-42BC-AEB9-EFD03777823F@microsoft.com... > Hi; > > For a single DbConnection, can I call DbCommand.ExecuteReader() for > several > selects and then for each reader call Read() and iterate through the rows. > I > have a situation where for my outer reader, for each row I need to call a > select and iterate through the inner list of rows. > > -- > thanks - dave Hi;
I'm .NET 2.0 only. Does that make a difference? If I go the DataSet route, then can I do this? -- Show quotethanks - dave "Sahil Malik [MVP]" wrote: > ..NET 1.1 / SQL2K world - No you can't. > > There is a new and shiny thing called MARS - but I would highly recommend > understanding it's implications before you start doing it. > > - Sahil Malik [MVP] > ADO.NET 2.0 book - > http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx > ---------------------------------------------------------------------------- > > "David Thielen" <thielen@nospam.nospam> wrote in message > news:3088DDC3-C6B0-42BC-AEB9-EFD03777823F@microsoft.com... > > Hi; > > > > For a single DbConnection, can I call DbCommand.ExecuteReader() for > > several > > selects and then for each reader call Read() and iterate through the rows. > > I > > have a situation where for my outer reader, for each row I need to call a > > select and iterate through the inner list of rows. > > > > -- > > thanks - dave > > > ..NET 2.0 will allow you to do MARS, but you shouldn't abuse it as there are
many side effects you need to be careful of. Check out my other reply for the rest of the story :). - Sahil Malik [MVP] ADO.NET 2.0 book - http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx ---------------------------------------------------------------------------- Show quote "David Thielen" <thielen@nospam.nospam> wrote in message news:8997BDA9-1805-494F-B428-BA91A452E8D4@microsoft.com... > Hi; > > I'm .NET 2.0 only. Does that make a difference? > > If I go the DataSet route, then can I do this? > > -- > thanks - dave > > > "Sahil Malik [MVP]" wrote: > >> ..NET 1.1 / SQL2K world - No you can't. >> >> There is a new and shiny thing called MARS - but I would highly recommend >> understanding it's implications before you start doing it. >> >> - Sahil Malik [MVP] >> ADO.NET 2.0 book - >> http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx >> ---------------------------------------------------------------------------- >> >> "David Thielen" <thielen@nospam.nospam> wrote in message >> news:3088DDC3-C6B0-42BC-AEB9-EFD03777823F@microsoft.com... >> > Hi; >> > >> > For a single DbConnection, can I call DbCommand.ExecuteReader() for >> > several >> > selects and then for each reader call Read() and iterate through the >> > rows. >> > I >> > have a situation where for my outer reader, for each row I need to call >> > a >> > select and iterate through the inner list of rows. >> > >> > -- >> > thanks - dave >> >> >> Hi Dave,
In .NET 2.0, you can use Multiple Active Result Sets to achieve this. That is open multiple DataReader on one connection object. However, this can only be done with SQL server 2005. Please check the following link for more information. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql90/htm l/MARSinSQL05.asp Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." |
|||||||||||||||||||||||