Thank you, but I need to use the same connection and not to close the first
"William Ryan" <dotnetguru@comcast.nospam.net> wrote in message
news:#2LFTPT2DHA.2160@TK2MSFTNGP12.phx.gbl...
> Close the first datareader or use the CommandBehavior.CloseConnection
>
www.knowdotnet.com/articles/schemas2.html > . If you close the reader, you won't have to reopen the connection which
> may or may not be appropriate depending on your particular needs. ANother
> thing...you may want to use a new connection and just reuse the
> connectionstring and throw in a try/catch/finally to make sure things get
> cleaned up if anything goes wrong.
>
> HTH,
>
> Bill
> "Marina" <someone@nospam.com> wrote in message
> news:eHbTLmS2DHA.2680@tk2msftngp13.phx.gbl...
> > It is not possible to have 2 open data readers on the same connection at
> the
> > same time.
> >
> > Either use 2 connections, or use a datatable/dataset for the result of
one
> > or both of your queries.
> >
> > "Ruslan" <ruslan_albu@hotmail.com> wrote in message
> > news:eKU9WgS2DHA.3416@tk2msftngp13.phx.gbl...
> > > Hello,
> > >
> > >
> > >
> > > I have:
> > >
> > >
> > >
> > >
> > >
> > > Method1()
> > >
> > > {
> > >
> > > SqlDataReader dr = new DataReader();
> > >
> > > ...
> > >
> > > while (dr.Read)
> > >
> > > {
> > >
> > > Method2()
> > >
> > > }
> > >
> > > }
> > >
> > >
> > >
> > > Method2()
> > >
> > > {
> > >
> > > SqlDataReader dr = new DataReader();
> > >
> > > ...
> > >
> > > while (dr.Read)
> > >
> > > {
> > >
> > > Method2()
> > >
> > > }
> > >
> > > }
> > >
> > >
> > >
> > > I use the same connection for both SqlDataReader. It's logically what
> > error
> > > appears, when the "dr.Read()" from the "Method2 is called, because
there
> > is
> > > one open connection for the first SqldDataReader. Is it possible to do
> > > something what the both SqlDataReader use the same connection?
> > >
> > >
> > >
> > > Thanks,
> > >
> > >
> > >
> > > Ruslan
> > >
> > >
> >
> >
>
>