Recent

Author Topic: TBufDataset can't add new field after copyfromdataset  (Read 1628 times)

Fantablup

  • Full Member
  • ***
  • Posts: 140
TBufDataset can't add new field after copyfromdataset
« on: July 01, 2021, 10:45:01 am »
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

  • Full Member
  • ***
  • Posts: 187
Re: TBufDataset can't add new field after copyfromdataset
« Reply #1 on: July 01, 2021, 11:20:53 am »
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

  • Full Member
  • ***
  • Posts: 140
Re: TBufDataset can't add new field after copyfromdataset
« Reply #2 on: July 01, 2021, 11:23:12 am »
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.
« Last Edit: July 01, 2021, 11:26:45 am by Fantablup »

Fantablup

  • Full Member
  • ***
  • Posts: 140
Re: TBufDataset can't add new field after copyfromdataset
« Reply #3 on: July 01, 2021, 11:30:19 am »
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

  • Hero Member
  • *****
  • Posts: 828
Re: TBufDataset can't add new field after copyfromdataset
« Reply #4 on: July 01, 2021, 12:11:47 pm »
I’m afraid you cannot do that. Create bufdataset first and copy data from source dataset using two whiles.

Fantablup

  • Full Member
  • ***
  • Posts: 140
Re: TBufDataset can't add new field after copyfromdataset
« Reply #5 on: July 01, 2021, 01:47:08 pm »
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.

 

TinyPortal © 2005-2018