Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Firedac ExecSQL error


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Apr 12, 2018 9:07 AM Last Post By: Barry Wood
Barry Wood

Posts: 73
Registered: 9/3/01
Firedac ExecSQL error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 10, 2018 8:59 AM
Hi,
I'm using FireDacs EXECSQL functionality to update a record in an MSSQL table. Here is the gist of the code:

with dm.tSeniorsTeams do
begin
First;
While NOT EOF do
begin
ExecSQL( 'UPDATE tSeniorsTeams SET PlayerA = :pReserve WHERE MatchID = :pEvent AND PlayerA = :pPlayerA', [ iReserve, gviMatchID, iPlayerA ] );
Next;
end;
end;

I can see (looking directly at the table) that the ExecSQL does indeed do the update operation, so the parameters shown are all OK and the format is good.

However, as soon as I go to the next line - 'Next;' I get an error: 'tSeniorsTeams: Cannot perform this operation on a closed dataset'

Can anybody help explain this, please? The query is active, s something else?o what is missing from the above code to stop this error message? Is it a FireDac error or something else?
Barry Wood

Posts: 73
Registered: 9/3/01
Re: Firedac ExecSQL error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 12, 2018 9:07 AM   in response to: Barry Wood in response to: Barry Wood
Hi,
Sorry to have asked this, my bad! I've fixed the problem it wasn't my code below, something else.
Barry Wood wrote:
Hi,
I'm using FireDacs EXECSQL functionality to update a record in an MSSQL table. Here is the gist of the code:

with dm.tSeniorsTeams do
begin
First;
While NOT EOF do
begin
ExecSQL( 'UPDATE tSeniorsTeams SET PlayerA = :pReserve WHERE MatchID = :pEvent AND PlayerA = :pPlayerA', [ iReserve, gviMatchID, iPlayerA ] );
Next;
end;
end;

I can see (looking directly at the table) that the ExecSQL does indeed do the update operation, so the parameters shown are all OK and the format is good.

However, as soon as I go to the next line - 'Next;' I get an error: 'tSeniorsTeams: Cannot perform this operation on a closed dataset'

Can anybody help explain this, please? The query is active, s something else?o what is missing from the above code to stop this error message? Is it a FireDac error or something else?
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02