Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
30 Points
38 Posts
May 01, 2012 05:44 AM|LINK
Chen Yu - MSFT lionelsiu Is it possible to have a SQLreader within a SQLreader, without opening another connection? Thank you! ... OleDbDataReader SqlReader = cmd.ExecuteReader(); while (sqlReader.Read()) { OleDbDataReader SqlReader2 = cmd.ExecuteReader(); } Hi, Would you please tell us what do you want to finish by above code? Thanks.
lionelsiu Is it possible to have a SQLreader within a SQLreader, without opening another connection? Thank you! ... OleDbDataReader SqlReader = cmd.ExecuteReader(); while (sqlReader.Read()) { OleDbDataReader SqlReader2 = cmd.ExecuteReader(); }
Is it possible to have a SQLreader within a SQLreader, without opening another connection? Thank you!
... OleDbDataReader SqlReader = cmd.ExecuteReader(); while (sqlReader.Read()) { OleDbDataReader SqlReader2 = cmd.ExecuteReader(); }
Hi,
Would you please tell us what do you want to finish by above code?
Thanks.
The first SqlReader is to find IDs from TABLE1 ( There can be no ID, 1 ID or more than 1 ID).
Then, the second SqlReader will use the IDs from TABLE1:
SELECT * FROM TABLE2 WHERE TABLE1.ID = TABLE2.ID
for each ID, there will be no. of records, I want to find the top 2 records group by each ID.
Finally, the result should display top 2 records for each ID.
Thank you.
lionelsiu
Member
30 Points
38 Posts
Re: SQLReader in a SQLReader
May 01, 2012 05:44 AM|LINK
The first SqlReader is to find IDs from TABLE1 ( There can be no ID, 1 ID or more than 1 ID).
Then, the second SqlReader will use the IDs from TABLE1:
SELECT * FROM TABLE2 WHERE TABLE1.ID = TABLE2.ID
for each ID, there will be no. of records, I want to find the top 2 records group by each ID.
Finally, the result should display top 2 records for each ID.
Thank you.