The majority of my code for accessing a Stored Procedure dataset (MS SQL Server, forward-only, readonly) is a fallback to my Clipper coding from many years ago
In code review today, I noticed a reference to IsEmpty instead in a similar block of code. Is this just a preference or is there any real difference in the example scenario?
MyStoredProc.Open;
if not MyStoredProc.IsEmpty then
begin
DoSomething;
end;
Where I usually use
MyStoredProc.Open;
if not MyStoredProc.Eof then
begin
DoSomething;
end;
Mostly because it mirrors the practice of what I use in a while loop when it’s more than one record:
MyStoredProc.Open;
while not MyStoredProc.Eof then
begin
DoSomething;
MyStoredProc.Next;
end;
The IsEmpty property is for check if the dataset has records, and Eof is for check if the current record is the last. In your case if you need iterate over a dataset use eof to determine if you reach the last record.