skipping first row

Topics: Data Access Application Block
Oct 15, 2008 at 9:41 PM

My code to create a datareader is :


cmdGetData= Adapter.GetStoredProcCommand("uspGetData");


  dataReader= Adapter.ExecuteReader(cmdGetData);

Following is the code I am using to read the data:







when  I do this, It is skipping the first row.. It seems when is executed for first time, the pointer is already is on first row and skipping over to second row..
Is there any other way to loop on the Datareader when I created it using DAAB classes??

Oct 16, 2008 at 2:10 AM
I would suspect the Adapter class is probably calling reader.Read() to check to see if there is any data or to prime the reader. You can use the following boiler plate code to validate the DAAB classes work as expected. I am sure if there was this obvious bug in the code it would have been caught. In the future, it can be helpful to include the version of the Enterprise Library that you are working with.
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetStoredProcCommand(sql);
using (IDataReader dataReader = db.ExecuteReader(cmd))
//do something