The error occurs in method setNewRow at the first GetString() . The
entry point is the ExecuteRelatorio() method.
protected void setNewRow(int loopIndex, DataTable
dtRet,Abit.Comex.Data.DataReader dr)
{
DataRow newRow = dtRet.NewRow();
newRow[0] = dr.Reader.GetString(0);
dr.Reader.GetInt32(1);
if(dr.Reader[2] != DBNull.Value)
newRow[2] =
dr.Reader.GetString(2);
if(dr.Reader[3] != DBNull.Value)
newRow[loopIndex+3] =
dr.Reader.GetDouble(3);
if(dr.Reader[4] != DBNull.Value)
newRow[loopIndex+4] =
dr.Reader.GetDouble(4);
dtRet.Rows.Add(newRow);
}
public DataTable ExecuteRelatorio(IRelatorioExecution
DataClassExecution, TypeRelatorio TipoRelatorio,string FiltroNCMIni,
string FiltroNCMFinal, params DateTime[] Dates)
{
DataTable dtRet = GetRelatorioDataTable(Dates);
HelperCommand HComm = null;
for(int i = 0; i < Dates.Length; i=i+2)
{
if(TipoRelatorio ==
TypeRelatorio.Exportacao) HComm =
DataClassExecution.ExecuteRelatorioExp(FiltroNCMIni, FiltroNCMFinal,
Dates[i],Dates[i+1]);
else HComm =
DataClassExecution.ExecuteRelatorioImp(FiltroNCMIni,
FiltroNCMFinal, Dates[i],Dates[i+1]);
DataReader dr =
HComm.ExecuteReader(CommandBehavior.CloseConnection);
if(dr.Reader.IsClosed) return(dtRet);
while (dr.Reader.Read())
{
if(i==0) setNewRow(i,dtRet,dr);
else
{
string NCM =
dr.Reader.GetString(0);
int ID =
dr.Reader.GetInt32(1);
DataRow[] rows =
dtRet.Select("ID=" + ID + " and NCM ='"+ NCM
+"'");
if(rows.Length == 0)
setNewRow(i,dtRet,dr);
else
{
rows[0][i+3] =
dr.Reader.GetDouble(3);
rows[0][i+4] =
dr.Reader.GetDouble(4);
}
}
}
dr.Reader.Close();
HComm.CommandDisponse();
}
HComm.Finish();
return(dtRet);
}
> It's hard to tell what's happening to cause the exception to be thrown
> without the code where the error is occurring. Could you copy a few lines of
[quoted text clipped - 4 lines]
>
> Allen Andersn