求解..这段代码为什么成了死循环...
qryDrLj的记录数只有1..但是这个循环死活跳不出去...特来求解..我看不出死在什么地方了..
这是一个根据表中记录自动打开EXCEL导入EXCEL中数据的代码.
for(qryDrLj->First(); !qryDrLj->Eof; qryLygs->Next()) { m_Jclx = qryDrLj->FieldByName("jczl")->AsString; if(qryDrLj->FieldByName("bbxz")->AsString == "日报") { sFieldName = FormatDateTime("yyyymmdd", dxbrdtcmbRq->Date); sBblx = "RB"; } else if(qryDrLj->FieldByName("bbxz")->AsString == "月报") { sFieldName = FormatDateTime("yyyymm", StartOfTheMonth(dxbrdtcmbRq->Date)); sBblx = "YB"; } if(qryDrLj->FieldByName("cjdm")->AsString == "YGJJ") { //待特殊处理. } else { //拼接文件路径 AnsiString sParth = qryDrLj->FieldByName("bclj")->AsString + "\\" + sFieldName + ".xls"; if(sFieldName.Length() == 8) { sXtrq = sFieldName.SubString(1,4) + "-" + sFieldName.SubString(5,2) + "-" + sFieldName.SubString(7,2); } else { sXtrq = sFieldName.SubString(1,4) + "-" + sFieldName.SubString(5,2) + "-01"; } if(qryDrLj->FieldByName("bbxz")->AsString == "月报") { //判断文件路径是否存在,存在就执行IF里面的代码. if(GetParth(qryDrLj->FieldByName("bclj")->AsString,sFieldName) == true) { ExcelApp.PG("workbooks").FN("open", sParth.c_str()); Workbook1 = ExcelApp.PG("ActiveWorkBook"); Workbook1.PG("Sheets", 1).PR("Select"); Sheet1 = Workbook1.PG("ActiveSheet"); sSQL.printf("delete dat_sy_yycj where bbxz = '%s' and cjdm = '%s' and xtrq = '%s' ",sBblx,qryDrLj->FieldByName("cjdm")->AsString,sXtrq); qryTmp->SQL->Text = sSQL; qryTmp->ExecSQL(); PostYycj(sBblx,qryDrLj->FieldByName("cjdm")->AsString,sXtrq,ExcelApp,Workbook1,Sheet1); } } } }