首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi 局部变量赋值 有关问题 急 在线

2012-09-08 
delphi 局部变量赋值 问题 急 在线for i: 0 to SelectedList.Count-1 dobeginGotoBookmark(SelectedList.

delphi 局部变量赋值 问题 急 在线
for i:= 0 to SelectedList.Count-1 do
  begin
  GotoBookmark(SelectedList.items[i]);
  strOldReg_ID:='';
  //OldAcc_date :=StrToDate(trim(FieldByName('acc_date').AsString));
  strOldReg_ID :=trim(FieldByName('register_id').AsString);
  if (strOldReg_ID <> '') then
  begin
  strNewReg_ID :=CreateRegisterID;

  OldAcc_date :=FormatDateTime('yyyy-mm-dd',StrToDate(trim(FieldByName('acc_date').AsString)));
  NewAcc_date :=FormatDateTime('yyyy-mm-dd',dbNewDate.Date);
  date_bt :=Trunc(StrToDate(NewAcc_date)-StrToDate(OldAcc_date));
  strUpdate := Format(strUpdate,[strNewReg_ID,StrToInt(strOldReg_ID),NewAcc_date,strOldReg_ID)]); strLogUpdate :='update flo_actlog f set f.signdate=signdate+%d,f.completedate=completedate+%d,f.bpactid=''%s'' where BPACTID=''%s''';
  strLogUpdate := Format(strLogUpdate,[date_bt,date_bt,strNewReg_ID,copy(strOldReg_ID,2,7)]);


  if not query_exec(Database.DatabaseName, strUpdate) then
  raise exception.Create('更新app_accountpro失败:'+ strUpdate);
  if not query_exec(Database.DatabaseName,strLogUpdate) then
  raise exception.Create('插入flo_actlog失败:' + strLogUpdate);
  end;

循环时第一次没有问题 strOldReg_ID ='1' 此时strUpdate 'update ...where id=1'
第二次strOldReg_ID ='2' 但是strUpdate 的strOldReg_ID 还是等于'1' 没有被重新赋值。此时strUpdate 还是 'update ...where id=1'

请帮忙,急。。。在线
 

[解决办法]

探讨
循环里加一个strUpdate :='';就可以了。

[解决办法]
strUpdate 资源未释放

热点排行