问题
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