错误信息"Operation is not allow when the object is open"是什么原因引起的,该怎么解决?
我的写的程序,在一次运行时报错后,执行程序一打开就出现上面的错误,程序根本就无法运行。
出错信息指的是我连接数据库时的代码,代码如下:
=====================
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




