if CB1.Checked = true then
        begin
            Ndm.AQ_common.Close;
            Ndm.AQ_common.SQL.Clear;
            Ndm.AQ_common.SQL.Add('delete courses where type = 31 and a_id = '''+inttostr(criterions_id)+'''');
            Ndm.AQ_common.ExecSQL;
            CB1.Checked := false;
            exit;
        end
    else
        begin
            Ndm.AQ_common.Close;
            Ndm.AQ_common.SQL.Clear;
            Ndm.AQ_common.SQL.Add('insert into courses (a_id,type) values ('''+inttostr(criterions_id)+''',31)');
            Ndm.AQ_common.ExecSQL;
            CB1.Checked := true;
            exit;
        end;

解决方案 »

  1.   

    'delete from courses ..------我怎么没有看到循环??
      

  2.   

    checked := false; 触发了事件 应该如此
      

  3.   

    晕。肯定死。设置为TRUE以后又设置为FALSE就这样循环着。
      

  4.   

    if else 结构没有问题,死循环原因应该在sql语句上,建议设断点跟在一下
      

  5.   

    procedure TNcours_shoot.FormActivate(Sender: TObject);
    begin
        try
        Ndm.AQ_common.Close;
        Ndm.AQ_common.SQL.Clear;
        Ndm.AQ_common.SQL.Add('select * from courses where type = 31 and a_id = '''+inttostr(criterions_id)+'''');
        Ndm.AQ_common.Open;
        if not Ndm.AQ_common.Eof then
            begin
                CB1.Checked := true;
            end;
        except
        end;    try
        Ndm.AQ_common.Close;
        Ndm.AQ_common.SQL.Clear;
        Ndm.AQ_common.SQL.Add('select * from courses where type = 32 and a_id = '''+inttostr(criterions_id)+'''');
        Ndm.AQ_common.Open;
        if not Ndm.AQ_common.Eof then
            begin
                CB2.Checked := true;
            end;
        except
        end;
    end;