数据库连接有关问题-"对象打开时,不允许操作"
数据库连接问题--"对象打开时,不允许操作"
在数据模块的OnCreate事件中,设置数据库连接串、激活数据集,手工完成初始化工作:
procedure TDMMain.DataModuleCreate(Sender: TObject);
begin
adoCon.ConnectionString := ADO_STRING;
adtBook.Active := True; //此行提示出错!
adtPub.Active := True;
end;
Debugger Exception Notification:
Project BOOK.exe raised exception class EOleException with message '对象打开时,不允许操作。 '.Process stopped.Use Step or Run to continue.
View CPU Window
请各位大虾来帮忙解决一下!小弟在此谢谢了!
------解决方案--------------------
先关闭连接之后再连接
connection.close;
connection.open;
在数据模块的OnCreate事件中,设置数据库连接串、激活数据集,手工完成初始化工作:
procedure TDMMain.DataModuleCreate(Sender: TObject);
begin
adoCon.ConnectionString := ADO_STRING;
adtBook.Active := True; //此行提示出错!
adtPub.Active := True;
end;
Debugger Exception Notification:
Project BOOK.exe raised exception class EOleException with message '对象打开时,不允许操作。 '.Process stopped.Use Step or Run to continue.
View CPU Window
请各位大虾来帮忙解决一下!小弟在此谢谢了!
------解决方案--------------------
先关闭连接之后再连接
connection.close;
connection.open;