TBufDataset can't add new field after copyfromdataset lazarus / 16-Databases ---------------------------------------------------------------------- Fantablup · 2021-07-01 08:45 I have tried TBufDataset, TMemDatataset and ZMSQL. Totally impossible to add new field after copying a SQL dataset into any memory dataset. I am able to add new fields with createdataset, but then i cant load dataset from an SQL dataset like TQuery or ZQUERY. I gave up using any of them. I needed to add a row number that not change when sorting. Important for updating in a result dataset. I made it without using them, but i have spent almost two days trying to get it to work, but no go. It is only when using copyfromdataset it will not work. Maybe someone knows how if i need it later. ---------------------------------------------------------------------- korba812 · 2021-07-01 09:20 You cannot add a new field while the DataSet is active. You have to create your own function that copies the structure first, then adds an extra field, and finally copies the data. ---------------------------------------------------------------------- Fantablup · 2021-07-01 09:23 I tried that too. Copying the fielddefs from the tquery, and then add a new field. No go. After copyfromdataset, it is not working. The new field is lost. It exists none examples on web either on just this. Not even in any examples in the packages. ---------------------------------------------------------------------- Fantablup · 2021-07-01 09:30 I was able to manually copy the query into the memtable with a while not eof loop. But it will not work when using copyfromdataset. ---------------------------------------------------------------------- egsuh · 2021-07-01 10:11 I’m afraid you cannot do that. Create bufdataset first and copy data from source dataset using two whiles. ---------------------------------------------------------------------- Fantablup · 2021-07-01 11:47 Thanks for all help guys😀 I guess I figured that out, after two days😀 I just wanted to bypass that, with only doing copyfromdataset. But I got all data the manual way with copying all columns in each row. But, then I found another solution. I can manually sort the stringrid instead with the izresultset, and not have to use extra memory datasets for it.