Miha
Thu Jan 25 02:10:19 CST 2007
Hi David,
Why don't you create a stored procedure instead?
You can also check out MARS (Multiple Active Result Sets) capability - I am
not sure whether it will help you or not.
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog:
http://cs.rthand.com/blogs/blog_with_righthand/
"David Thielen" <thielen@nospam.nospam> wrote in message
news:21FCC985-08E2-4FFB-BFF7-5AD275A7C8D3@microsoft.com...
> Unfortunately we have N rows for the first select so that approach is a
> mess.
> We can do it if we have to, but I am hoping someone here knows of an
> alternative.
>
> --
> thanks - dave
> david_at_windward_dot_net
>
http://www.windwardreports.com
>
> Cubicle Wars -
http://www.windwardreports.com/film.htm
>
>
>
>
> "Stephany Young" wrote:
>
>> Que?
>>
>> Do you mean that you are concerned that a row of interest in table2 could
>> be
>> updated after you execute the select on table1 but before you execute the
>> inner select on table2?
>>
>> Try, using one SqlDataReader
>>
>> begin transaction;
>> select * from table1;
>> select * from table2 where pk in (select fk from table1);
>> end transaction;
>>
>> When you have finished cycling through the SqlDataReader (table1) then
>> execute it's NextResult method and cycle through it again for table2.
>>
>> You can do it one way or you can do it the other way, but you can't do it
>> both ways at once.
>>
>>
>> "David Thielen" <thielen@nospam.nospam> wrote in message
>> news:40940EA9-547A-458B-BCB6-1B8BD52E91DF@microsoft.com...
>> > Hi;
>> >
>> > I need the transaction because otherwise I can end up with two objects
>> > that
>> > do not match. There must be a way to do this as it's pretty basic and I
>> > think
>> > a lot of people would need this.
>> >
>> > --
>> > thanks - dave
>> > david_at_windward_dot_net
>> >
http://www.windwardreports.com
>> >
>> > Cubicle Wars -
http://www.windwardreports.com/film.htm
>> >
>> >
>> >
>> >
>> > "Stephany Young" wrote:
>> >
>> >> Any SqlConnection object can only have one active SqlDataReader at a
>> >> time.
>> >>
>> >> To do what you need to do you need to have a second SqlConnection
>> >> object
>> >> for
>> >> the inner SqlDataReader.
>> >>
>> >> I do not think that a 'transaction' can span multiple connections.
>> >>
>> >> It appears that you are only 'reading' so there does not appear to be
>> >> any
>> >> need for a transaction.
>> >>
>> >>
>> >> "David Thielen" <thielen@nospam.nospam> wrote in message
>> >> news:B99A7816-4975-476B-B0D6-52C32359CA13@microsoft.com...
>> >> > ps - with all of this within the same transaction.
>> >> >
>> >> > --
>> >> > thanks - dave
>> >> > david_at_windward_dot_net
>> >> >
http://www.windwardreports.com
>> >> >
>> >> > Cubicle Wars -
http://www.windwardreports.com/film.htm
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > "David Thielen" wrote:
>> >> >
>> >> >> Hi;
>> >> >>
>> >> >> I need to call SqlCommand.ExecuteReader and then inside a while
>> >> >> (reader.Read()) I need to call another SqlCommand.ExecuteReader. I
>> >> >> need
>> >> >> to do
>> >> >> this because I have a FK:PK relationship and based on the FK read,
>> >> >> then
>> >> >> read
>> >> >> the row in that related table - if the FK is not null.
>> >> >>
>> >> >> How can I do this?
>> >> >>
>> >> >> --
>> >> >> thanks - dave
>> >> >> david_at_windward_dot_net
>> >> >>
http://www.windwardreports.com
>> >> >>
>> >> >> Cubicle Wars -
http://www.windwardreports.com/film.htm
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>