定时导库出现问题!!
if(Now() == StrToDateTime(DateToStr(Date())+" 03:00:00")) { rzstspn1->Caption="数据库开始操作!!"; //控制状态栏 rzstspn1->Refresh(); String sysdate=" a.xtrq = '"+FormatDateTime("yyyy-mm-dd",Date())+"' "; //定义要导的数据的时间, String sysdate1=" xtrq = '"+FormatDateTime("yyyy-mm-dd",Date())+"' "; Translate(Application,sysdate,sysdate1); room->qry_bdsjb_ls->Close(); room->qry_bdsjb_ls->SQL->Clear(); room->qry_bdsjb_ls->SQL->Add("delete from lrkh_bdsjb_ls"); //将零时表的数据删除 room->qry_bdsjb_ls->ExecSQL(); room->qry_bdsjb_ls->Close(); rzstspn1->Caption="数据库空闲!!"; rzstspn1->Refresh(); mm=0; } else { rzstspn1->Caption="数据库空闲!!"; rzstspn1->Refresh(); }
static bool bTurn=true; if(Now().FormatString("hh")=="03" && bTurn==true) { bTurn=false; rzstspn1->Caption="数据库开始操作!!"; //控制状态栏 rzstspn1->Refresh(); String sysdate=" a.xtrq = '"+FormatDateTime("yyyy-mm-dd",Date())+"' "; //定义要导的数据的时间, String sysdate1=" xtrq = '"+FormatDateTime("yyyy-mm-dd",Date())+"' "; Translate(Application,sysdate,sysdate1); room->qry_bdsjb_ls->Close(); room->qry_bdsjb_ls->SQL->Clear(); room->qry_bdsjb_ls->SQL->Add("delete from lrkh_bdsjb_ls"); //将零时表的数据删除 room->qry_bdsjb_ls->ExecSQL(); room->qry_bdsjb_ls->Close(); rzstspn1->Caption="数据库空闲!!"; rzstspn1->Refresh(); mm=0; } else if(Now().FormatString("hh")=="04") { bTurn=true; rzstspn1->Caption="数据库空闲!!"; rzstspn1->Refresh(); }
[解决办法]
改一下上面的代碼:
static bool bTurn=true; if(Now().FormatString("hh")=="03" && bTurn==true) { bTurn=false; rzstspn1->Caption="数据库开始操作!!"; //控制状态栏 rzstspn1->Refresh(); String sysdate=" a.xtrq = '"+FormatDateTime("yyyy-mm-dd",Date())+"' "; //定义要导的数据的时间, String sysdate1=" xtrq = '"+FormatDateTime("yyyy-mm-dd",Date())+"' "; Translate(Application,sysdate,sysdate1); room->qry_bdsjb_ls->Close(); room->qry_bdsjb_ls->SQL->Clear(); room->qry_bdsjb_ls->SQL->Add("delete from lrkh_bdsjb_ls"); //将零时表的数据删除 room->qry_bdsjb_ls->ExecSQL(); room->qry_bdsjb_ls->Close(); mm=0; } else if(Now().FormatString("hh")=="04") { bTurn=true; } rzstspn1->Caption="数据库空闲!!"; rzstspn1->Refresh();