Cannot perform this operation on a closed dataset

孤人 提交于 2020-01-21 14:45:31

问题


I am just trying to execute the "select" sql statement using TADOQuery component, but when TADOQuery's "Open" statement is executing I am getting following error:

Cannot perform this operation on a closed dataset... 
ADOQuery1.Active := False;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Select * from Table1 where Column1 = <value>');
ADOQuery1.Open;

Any guess why I am getting this error ?


回答1:


Your code looks fine.

Check if there are any event handlers (OnBeforeOpen) or master/detail datasources attached to the query. In this case a different dataset, which is still closed, could cause the error.




回答2:


The issue is resolved, I am using SQL Server 2008 as database.

Here "SetAppRole" was not applied on the database, after applying it, now there is no error.



来源:https://stackoverflow.com/questions/13288084/cannot-perform-this-operation-on-a-closed-dataset

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!