delphitclientdataset

Inserting after the last record (bottom) shown in DBGrid


What should be the code for inserting after the last record using the ClientDataSet?

I tried the following:

cdsSomething.Last;
cdsSomething.Insert:

But it appears it replaces the last record instead. I am sure there must be a quick code for this.


Solution

  • The method to append a record to the end of the Dataset (let alone any index) is Append. You don't even need to call Last before.

    cdsSomething.Append;
    

    Insert inserts a row before the selected record, so with your code, the new record should become the second to last record.