I am using while (reader.Read() ) to read the rows from excel spreadsheet and want to exit when the last row has been read. I am using the code below. Some how it is always selecting one extra row.
Any help would be appreciated.




while (reader.Read() )
{
string AgentID = Convert.ToString(reader["Sales ID"]);
string Notes = Convert.ToString(reader["Notes"]);
string AdjAmount = Convert.ToString(reader["Adjustment"]);
string AdjustmentType = "";

if ((AdjAmount == null) || (AgentID == null) || (Notes == null))
{
r = 3; //return value to the calling method
}
else
{
if (Convert.ToString(reader[3]) == "")
{
r = imp.Insert_tblSummaryAdjustment_New("", AdjAmount, AgentID, Notes, xlsheetname, year, month);


import.Update_tblSummaryAdjustment(AgentID);
}
else
{


AdjustmentType = Convert.ToString(reader["AdjustmentType"]);
//AdjustmentType = Convert.ToString(reader[1]);



r = imp.Insert_tblSummaryAdjustment(AdjustmentType, AdjAmount, AgentID, Notes, xlsheetname, year, month);


}

}

}

reader.Close();