Dear Experts,
I am trying to execute a store procedure using the OleDbCommand.ExecuteReader() method. The stored proc returns 64 rows. Although, the program is successfully executing the stored proc, but it throws a runtime Null Reference exception after retrieving few rows. I am retrieving these rows through a OleDbDataReader object. The strange thing is that the program throws the exception randomly at any row. That is, sometime it fails while reading 8th row or sometime at 22nd row or 29th row.
OleDbCommand ObjCmd = new OleDbCommand(SPName, objConnect);
OleDbDataReader ResultSet;
ObjCmd.CommandType = CommandType.StoredProcedure;
ObjCmd.Parameters.Add(param); //param is an OleDbparameter object
ResultSet = ObjCmd.ExecuteReader();
while (ResultSet.Read())
{
Console.WriteLine("{0,25} {1,25:dd-MMM-yy} {2,25} {3,25:C}",ResultSet.GetString(0), ResultSet.GetDateTime(1), ResultSet.GetInt32(2), ResultSet.GetDecimal(3));
}
ResultSet.Close();
Pls. advise.
Thanks in advance,
Susmita
I am trying to execute a store procedure using the OleDbCommand.ExecuteReader() method. The stored proc returns 64 rows. Although, the program is successfully executing the stored proc, but it throws a runtime Null Reference exception after retrieving few rows. I am retrieving these rows through a OleDbDataReader object. The strange thing is that the program throws the exception randomly at any row. That is, sometime it fails while reading 8th row or sometime at 22nd row or 29th row.
OleDbCommand ObjCmd = new OleDbCommand(SPName, objConnect);
OleDbDataReader ResultSet;
ObjCmd.CommandType = CommandType.StoredProcedure;
ObjCmd.Parameters.Add(param); //param is an OleDbparameter object
ResultSet = ObjCmd.ExecuteReader();
while (ResultSet.Read())
{
Console.WriteLine("{0,25} {1,25:dd-MMM-yy} {2,25} {3,25:C}",ResultSet.GetString(0), ResultSet.GetDateTime(1), ResultSet.GetInt32(2), ResultSet.GetDecimal(3));
}
ResultSet.Close();
Pls. advise.
Thanks in advance,
Susmita