J
Joe
Please don't bother responding about "Read(), MoveNext(), or
HasRows()"
It's obvious that .Net does not have a BOF check, which despite the
presumptuous claims by some that it's not needed, it really should be
exposed.
Therefore, I was hoping someone could come up with a clean/consistent
way to check for something that would throw an exception if the
DataReader (SqlDataReader in my case) was still at BOF.
I could then attempt to move the recordset forward within the 'catch'
block.
----------------------------------------------------------------------------
If any are doubting my need for this kind of functionality, since I
have read so many responses that irreverently state that no one should
ever need to know if a DataReader is at the BOF, here is my situation:
I have a business object has a constructor that takes a SqlDataReader
input parameter.
Sometimes, the SqlDataReader is passed from within a loop like:
ArrayList al = new ArrayList();
while (dr.Read())
{
al.Add(new BusinessObject(dr));
}
In this case, the SqlDataReader is already pointing to the record that
I need
In other cases, however, it would be convenient to pass in the results
of an ExecuteDataReader without having to move the recordset pointer
forward first, like:
BusinessObj obj = new BusinessObject(sql.ExecuteDataReader());
HasRows()"
It's obvious that .Net does not have a BOF check, which despite the
presumptuous claims by some that it's not needed, it really should be
exposed.
Therefore, I was hoping someone could come up with a clean/consistent
way to check for something that would throw an exception if the
DataReader (SqlDataReader in my case) was still at BOF.
I could then attempt to move the recordset forward within the 'catch'
block.
----------------------------------------------------------------------------
If any are doubting my need for this kind of functionality, since I
have read so many responses that irreverently state that no one should
ever need to know if a DataReader is at the BOF, here is my situation:
I have a business object has a constructor that takes a SqlDataReader
input parameter.
Sometimes, the SqlDataReader is passed from within a loop like:
ArrayList al = new ArrayList();
while (dr.Read())
{
al.Add(new BusinessObject(dr));
}
In this case, the SqlDataReader is already pointing to the record that
I need
In other cases, however, it would be convenient to pass in the results
of an ExecuteDataReader without having to move the recordset pointer
forward first, like:
BusinessObj obj = new BusinessObject(sql.ExecuteDataReader());