The problem occurs in the red code:
Int CurProductID = (int) odr ["Productid"];
While (CurProductID = (int) odr ["Productid"])
{
DateTime dt = (DateTime) odr ["OrderDate"];
Int FieldIndex = SumByMonth? (Dt. Month-1): (dt. Month-1)/3;
Report. DetailGrid. Recordset. Fields [m_AmtFieldIndexs [FieldIndex]. AsFloat ++ = (double) odr ["Amount"];
Report. DetailGrid. Recordset. Fields [m_QtyFieldIndexs [FieldIndex]. AsInteger + = (int) (Int16) odr ["Quantity"];
If (! Odr. Read ())
Break;
}
After modification by Bamboo:
Private void ReportFetchRecord (ref bool Eof)
{
OleDbConnection ocnnNorthwind = new OleDbConnection (GridppReportDemo. Utility. GetDatabaseConnectionString ());
OleDbCommand ocmd = new OleDbCommand ("select d. Productid, p. ProductName, m. OrderDate, d. Quantity, d. UnitPrice * d. Quantity * (1-d.Discount) as Amount"
+ "From orders m inner join ([Order Details] d inner join Products p on d. ProductID = p. ProductID )"
+ "On m. orderid = d. orderid"
+ "Where m. OrderDate between #1/1/97 # And #12/31/97 #"
+ "Order by d. Productid, m. OrderDate", ocnnNorthwind );
OcnnNorthwind. Open ();
OleDbDataReader odr = ocmd. ExecuteReader (CommandBehavior. CloseConnection );
Int primary roupcount = SumByMonth? 12: 4;
Int CurProductID =-1; // (int) odr ["ProductID"];
While (odr. Read ())
{
If (CurProductID! = (Int) odr ["ProductID"])
{
// Submit the previous data.
If (CurProductID> 0)
Report. DetailGrid. Recordset. Post ();
Report. DetailGrid. Recordset. Append ();
// Set the Initial Value
For (int I = 0; I <distinct roupcount; ++ I)
{
(IGRField) m_pAmtFields [I]). AsFloat = 0;
(IGRField) m_pQtyFields [I]). AsFloat = 0;
}
M_pProductIDField.Value = odr ["ProductID"];
M_pProductNameField.Value = odr ["ProductName"];
CurProductID = (int) odr ["ProductID"];
}
DateTime dt = (DateTime) odr ["OrderDate"];
Int FieldIndex = SumByMonth? (Dt. Month-1): (dt. Month-1)/3;
(IGRField) m_pAmtFields [FieldIndex]). AsFloat + = (double) odr ["Amount"];
(IGRField) m_pQtyFields [FieldIndex]). AsInteger + = (int) (Int16) odr ["Quantity"];
}
// Submit the last data.
Report. DetailGrid. Recordset. Post ();
Odr. Close ();
}
Http://www.rubylong.cn/bbs/dispbbs.asp? BoardID = 8 & ID = 4699 & page = 1