我的写的程序,在一次运行时报错后,执行程序一打开就出现上面的错误,程序根本就无法运行。出错信息指的是我连接数据库时的代码,代码如下:
=====================
    with DM_Main.ADOConn do
      begin
        connectionString:=sqlstr;
        try                    ( 此行为出错指定的行)
          open;  //打开数据库
          if Frm_DBConnection.visible then
            Frm_DBConnection.Close;        //判断打开是否成功,如果没有成功则打开配置数据库窗口Frm_DBConnection
        except
            on exception do
            If not Connected then
              begin
                ShowMessage('对不起,数据库连接出错,请重新配置数据连接参数!');
                if not Frm_DBConnection.visible then
                  begin
                    Frm_DBConnection.ShowModal;
                  end;
                Result:=False;
              end
             else
              begin
                if Frm_DBConnection.visible then
                  begin
                    Frm_DBConnection.Close;
                  end;
                Result:=True;              end;
        end;        Result:=True;

解决方案 »

  1.   

    with DM_Main.ADOConn do
          begin
            Close;//加这句我估计可以了
            connectionString:=sqlstr;
            try                    ( 此行为出错指定的行)
              open;  //打开数据库
              if Frm_DBConnection.visible then
                Frm_DBConnection.Close;        //判断打开是否成功,如果没有成功则打开配置数据库窗口Frm_DBConnection
            except
                on exception do
                If not Connected then
                  begin
                    ShowMessage('对不起,数据库连接出错,请重新配置数据连接参数!');
                    if not Frm_DBConnection.visible then
                      begin
                        Frm_DBConnection.ShowModal;
                      end;
                    Result:=False;
                  end
                 else
                  begin
                    if Frm_DBConnection.visible then
                      begin
                        Frm_DBConnection.Close;
                      end;
                    Result:=True;              end;
            end;        Result:=True;
      

  2.   

    Debugger窗口的信息:
    Project project1.exe raised exception Class EOleException with message "Operation is not allow when the object is open",Up,Help me,please!
      

  3.   

    huojiehai(海天子):老大,谢了,这样做是可以了。可是我不明白啊,我都没打开,他怎么要close呢?