How can start a new query if I'm already in a 'while(drSQL.Read){}??

  • Thread starter Thread starter trint
  • Start date Start date
T

trint

while (drSQL.Read())
{
In here I need to start a new query on a different table.
}
How can I do that?
Thanks,
Trint
 
trint,

You would have to open another connection to the database in order to do
this, as you couldn't do it on the one the data reader is currently acting
on.

Either that, or you could read the results into a dataset, and then
cycle through the rows.

However, the most efficient thing to do might be to flatten out the
table structure. I assume you would make a query based on the contents of
the current row. This assumes that there is a relation of some kind. It's
better to do it in the query itself, and let the DBMS handle that kind of
operation, and then just cycle through the results, noting when the
conditions on the outer groupings change.

Hope this helps.
 
best way: don't use datareader.

Get the data back in a dataset. Then, when you are going through the
resultset, you aren't constrained about what further information you need.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
Back
Top