F
Frank Schumacher
Hi NG,
I'd like to try a nested db query, that looks like this:
....
DataReader dr = _myCon.ExecuteReader("SELECT id from tableX where
parentID=1");
while (dr.Read())
{
DataReader dr2 = _myCon.ExecuteReader("SELECT id from tableX where
parentID=" + dr.GetInt32(0).ToString());
while (dr2.Read())
{
...
}
}
The probles is, as you will have recognized, that I can't open another
DataReader, before the first one is closed. The workaround for me till
now is to 1.) read all the entries from dr into a ArrayList and 2.)
close the dr and 3.) foreach the elements of the ArrayList to open the
next dr
This is ... well ... not quite sexy. There have to be another way 'round.
BTW: Is it possible to close a dr without having access to the
instancevariable? like: _myCon.CurrentDataReader.Close()?
Thanks in advance,
Frank
I'd like to try a nested db query, that looks like this:
....
DataReader dr = _myCon.ExecuteReader("SELECT id from tableX where
parentID=1");
while (dr.Read())
{
DataReader dr2 = _myCon.ExecuteReader("SELECT id from tableX where
parentID=" + dr.GetInt32(0).ToString());
while (dr2.Read())
{
...
}
}
The probles is, as you will have recognized, that I can't open another
DataReader, before the first one is closed. The workaround for me till
now is to 1.) read all the entries from dr into a ArrayList and 2.)
close the dr and 3.) foreach the elements of the ArrayList to open the
next dr
This is ... well ... not quite sexy. There have to be another way 'round.
BTW: Is it possible to close a dr without having access to the
instancevariable? like: _myCon.CurrentDataReader.Close()?
Thanks in advance,
Frank