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[] = {"Card Number"};
Variant pvrColumnNameumoney[] = {"User umoney"};
Variant pvrColumnNameAddmoneytime[] = {"Add Money Time"};
while(!ADOQuery_Report->Eof)
{
iCardNO = ADOQuery_Report->FieldByName("cardnum"->AsInteger;
strumoney = ADOQuery_Report->FieldByName("umoney"->AsString;
strAddmoneytime = ADOQuery_Report->FieldByName("date"->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行的数据的表需要一分钟多,我感觉不正常,
请大侠们指出我的代码的缺点,如何提高执行速度
小弟不胜感激!!
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[] = {"Card Number"};
Variant pvrColumnNameumoney[] = {"User umoney"};
Variant pvrColumnNameAddmoneytime[] = {"Add Money Time"};
while(!ADOQuery_Report->Eof)
{
iCardNO = ADOQuery_Report->FieldByName("cardnum"->AsInteger;
strumoney = ADOQuery_Report->FieldByName("umoney"->AsString;
strAddmoneytime = ADOQuery_Report->FieldByName("date"->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行的数据的表需要一分钟多,我感觉不正常,
请大侠们指出我的代码的缺点,如何提高执行速度
小弟不胜感激!!