CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Delphi >  VCL组件开发及应用

错误信息"Operation is not allow when the object is open"是什么原因引起的,该怎么解决?

楼主juwuyi(我有,我可以)2003-08-03 19:04:30 在 Delphi / VCL组件开发及应用 提问

我的写的程序,在一次运行时报错后,执行程序一打开就出现上面的错误,程序根本就无法运行。  
   
  出错信息指的是我连接数据库时的代码,代码如下:  
  =====================  
          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; 问题点数:100、回复次数:5Top

1 楼huojiehai(海天子)回复于 2003-08-03 19:09:05 得分 100

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;Top

2 楼juwuyi(我有,我可以)回复于 2003-08-03 19:10:16 得分 0

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

3 楼juwuyi(我有,我可以)回复于 2003-08-03 19:12:38 得分 0

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

4 楼huojiehai(海天子)回复于 2003-08-03 19:19:56 得分 0

你在设计时就激活了呀Top

5 楼huojiehai(海天子)回复于 2003-08-03 19:21:34 得分 0

结贴吧Top

相关问题

  • 为什么会出现"operation not allowed on a standalone feature object"的错误
  • circular datalink are not allow错误.
  • 求助:关于一个"Operation is not allowed when the object is open"的错误的问题!
  • "Object reference not set to an instance of an object":奇怪的错误
  • canvas dose not allow drawing错误
  • Invalid Variant Operation的错误?
  • 执行后出现错误, 错误提示: Could not create 'CDO.Message' object
  • “Method 'Visiable' not support by Automation Object'的错误.!!!!!!!
  • 请给出"not reference an automation object"错误详解
  • SmtpMail发送错误,Could not access 'CDO Message' object

关键词

  • 数据库
  • 连接
  • 信息
  • dbconnection
  • frm
  • 出错
  • 打开
  • visible then
  • 成功
  • begin

得分解答快速导航

  • 帖主:juwuyi
  • huojiehai

相关链接

  • Delphi类图书
  • Delphi类源码下载
  • Delphi控件下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo