Why didn’t they do this the first time?
I love DataReaders. You know this; I am a DataReader snob. I feel like a superior coder when I use a DataReader. Maybe it is my hatred of the false hype behind WebServices and XML that make me shun the DataSet. Or just my rather strange way of living my life. Who knows. Like most things you love in life, nothing is perfect. I have been using .NET 1.1 for over a year now since my company was an early adopter of Visual Studio 2003 and have gotten use to the HasRows property. For example if you want to test for an empty DataReader after you open it you can use code like this. (This code is more useful when you are NOT looping, but opening a DataReader for a single record.)
But what I forgot is that for .NET 1.0 (Visual Studio 2002), there is no HasRows property. You have to call the Read method which will return False when there are no rows. Here is the code. (Once again if you are in a loop, you would use a while Read=True and be done with it.)
So this works, but my ultimate question about HasRows is why didn’t they do this the first time?
Page rendered at Monday, November 30, 2020 2:41:21 AM (Eastern Standard Time, UTC-05:00)
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in anyway.