FastReport执行效率问题 ( 积分: 10 )

  • 主题发起人 主题发起人 flyskylf
  • 开始时间 开始时间
F

flyskylf

Unregistered / Unconfirmed
GUEST, unregistred user!
void __fastcall TForm_Report::frxReport_ReportBeforePrint(
  TfrxReportComponent *Sender)
{
   String strSQL;
  strSQL = "SELECT * FROM u_deposit WHERE cardnum = ";
  strSQL += suiNumberEdit_CardNum->Text;

  AnsiString strClassName = Sender->ClassName();
  if (strClassName == "TfrxCrossView")
  {
     TfrxCrossView *frxCrossView = dynamic_cast<TfrxCrossView*>(Sender);

     ADOQuery_Report->SQL->Clear();
     ADOQuery_Report->Close();
     ADOQuery_Report->SQL->Add(strSQL);
     ADOQuery_Report->Open();

     int iCardNO;
     AnsiString strumoney;
     AnsiString strAddmoneytime;

     int nRow = 0;

     Variant pvrColumnNameOfCardnum[] = {&quot;Card Number&quot;};
     Variant pvrColumnNameumoney[] = {&quot;User umoney&quot;};
     Variant pvrColumnNameAddmoneytime[] = {&quot;Add Money Time&quot;};

     while(!ADOQuery_Report->Eof)
     {
    iCardNO = ADOQuery_Report->FieldByName(&quot;cardnum&quot;)->AsInteger;
    strumoney = ADOQuery_Report->FieldByName(&quot;umoney&quot;)->AsString;
    strAddmoneytime = ADOQuery_Report->FieldByName(&quot;date&quot;)->AsString;

    Variant pvrRow[] = {nRow};
    Variant pvrCardNO[] = {iCardNO};
    Variant pvrumoney[] = {strumoney};
    Variant pvrAddmoneytime[] = {strAddmoneytime};

    frxCrossView->AddValue( (const Variant*)pvrRow, ARRAYSIZE(pvrRow)-1,
             (const Variant*)pvrColumnNameOfCardnum, ARRAYSIZE(pvrColumnNameOfCardnum)-1,
             (const Variant*)pvrCardNO, ARRAYSIZE(pvrCardNO)-1);

    frxCrossView->AddValue( (const Variant*)pvrRow, ARRAYSIZE(pvrRow)-1,
             (const Variant*)pvrColumnNameumoney, ARRAYSIZE(pvrColumnNameumoney)-1,
             (const Variant*)pvrumoney, ARRAYSIZE(pvrumoney)-1);

    frxCrossView->AddValue( (const Variant*)pvrRow, ARRAYSIZE(pvrRow)-1,
             (const Variant*)pvrColumnNameAddmoneytime, ARRAYSIZE(pvrColumnNameAddmoneytime)-1,
             (const Variant*)pvrAddmoneytime, ARRAYSIZE(pvrAddmoneytime)-1);

    ADOQuery_Report->Next();
    nRow++;
     }
  }
  
}
打印一个800行的数据的表需要一分钟多,我感觉不正常,
请大侠们指出我的代码的缺点,如何提高执行速度
小弟不胜感激!!
 
void __fastcall TForm_Report::frxReport_ReportBeforePrint(
  TfrxReportComponent *Sender)
{
   String strSQL;
  strSQL = &quot;SELECT * FROM u_deposit WHERE cardnum = &quot;;
  strSQL += suiNumberEdit_CardNum->Text;

  AnsiString strClassName = Sender->ClassName();
  if (strClassName == &quot;TfrxCrossView&quot;)
  {
     TfrxCrossView *frxCrossView = dynamic_cast<TfrxCrossView*>(Sender);

     ADOQuery_Report->SQL->Clear();
     ADOQuery_Report->Close();
     ADOQuery_Report->SQL->Add(strSQL);
     ADOQuery_Report->Open();

     int iCardNO;
     AnsiString strumoney;
     AnsiString strAddmoneytime;

     int nRow = 0;

     Variant pvrColumnNameOfCardnum[] = {&quot;Card Number&quot;};
     Variant pvrColumnNameumoney[] = {&quot;User umoney&quot;};
     Variant pvrColumnNameAddmoneytime[] = {&quot;Add Money Time&quot;};

     while(!ADOQuery_Report->Eof)
     {
    iCardNO = ADOQuery_Report->FieldByName(&quot;cardnum&quot;)->AsInteger;
    strumoney = ADOQuery_Report->FieldByName(&quot;umoney&quot;)->AsString;
    strAddmoneytime = ADOQuery_Report->FieldByName(&quot;date&quot;)->AsString;

    Variant pvrRow[] = {nRow};
    Variant pvrCardNO[] = {iCardNO};
    Variant pvrumoney[] = {strumoney};
    Variant pvrAddmoneytime[] = {strAddmoneytime};

    frxCrossView->AddValue( (const Variant*)pvrRow, ARRAYSIZE(pvrRow)-1,
             (const Variant*)pvrColumnNameOfCardnum, ARRAYSIZE(pvrColumnNameOfCardnum)-1,
             (const Variant*)pvrCardNO, ARRAYSIZE(pvrCardNO)-1);

    frxCrossView->AddValue( (const Variant*)pvrRow, ARRAYSIZE(pvrRow)-1,
             (const Variant*)pvrColumnNameumoney, ARRAYSIZE(pvrColumnNameumoney)-1,
             (const Variant*)pvrumoney, ARRAYSIZE(pvrumoney)-1);

    frxCrossView->AddValue( (const Variant*)pvrRow, ARRAYSIZE(pvrRow)-1,
             (const Variant*)pvrColumnNameAddmoneytime, ARRAYSIZE(pvrColumnNameAddmoneytime)-1,
             (const Variant*)pvrAddmoneytime, ARRAYSIZE(pvrAddmoneytime)-1);

    ADOQuery_Report->Next();
    nRow++;
     }
  }
  
}
打印一个800行的数据的表需要一分钟多,我感觉不正常,
请大侠们指出我的代码的缺点,如何提高执行速度
小弟不胜感激!!
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3240295
 
接受答案了.
 
后退
顶部