Recent

Author Topic: Copy data to tBufDataSet  (Read 5161 times)

cappe

  • Full Member
  • ***
  • Posts: 191
Copy data to tBufDataSet
« on: September 06, 2017, 12:10:29 pm »
I'm looking for the fastest method of copying a TZQuery (ZEOS) content (data) to a TBufDataSet.
It's urgent ...
« Last Edit: September 06, 2017, 12:20:47 pm by cappe »

rvk

  • Hero Member
  • *****
  • Posts: 6110
Re: Copy data to tBufDataSet
« Reply #1 on: September 06, 2017, 12:34:44 pm »
Code: Pascal  [Select][+][-]
  1. BufData.CopyFromDataset(Query1, true);
where BufData is a TBufDataSet and Query1 is TZQuery.
« Last Edit: September 06, 2017, 12:39:23 pm by rvk »

cappe

  • Full Member
  • ***
  • Posts: 191
Re: Copy data to tBufDataSet
« Reply #2 on: September 06, 2017, 04:07:18 pm »
Code: Pascal  [Select][+][-]
  1. BufData.CopyFromDataset(Query1, true);
where BufData is a TBufDataSet and Query1 is TZQuery.

Good, but I use Lazarus 1.2.6 e con not find CopyFromDataset. where can I find it or how can I do it?

rvk

  • Hero Member
  • *****
  • Posts: 6110
Re: Copy data to tBufDataSet
« Reply #3 on: September 06, 2017, 05:02:47 pm »
You could upgrade to a newer version where TBufDataset does have the function.

Otherwise you could try using TMemDataset (which had this function a lot longer).

I'm not sure what the downside would be for using TMemDataset. Maybe others can explain.

This page does give a remark about it:
http://wiki.freepascal.org/How_to_write_in-memory_database_applications_in_Lazarus/FPC
Quote
Note: later on in this article, BufDataset is introduced. TBufDataset often is a better choice than TMemDataset

So I'm not sure if you really need TBufDataset or if you can use TMemDataset (from memds).

cappe

  • Full Member
  • ***
  • Posts: 191
Re: Copy data to tBufDataSet
« Reply #4 on: September 07, 2017, 06:20:10 am »
You could upgrade to a newer version where TBufDataset does have the function.

Sorry, it's not so long that I use lazarus. How do I upgrade to the new version of TBufDataset with Lazarus 1.2.6?

p.s.: Thanks for the previous answer
« Last Edit: September 07, 2017, 07:19:55 am by cappe »

rvk

  • Hero Member
  • *****
  • Posts: 6110
Re: Copy data to tBufDataSet
« Reply #5 on: September 07, 2017, 09:35:35 am »
How do I upgrade to the new version of TBufDataset with Lazarus 1.2.6?
You can download the newest Lazarus 1.6.4 from the Lazarus homepage.

I'm not sure if you can just install over your current 1.2.6 but you can uninstall that one and install the new 1.6.4.

Also notice that the default download for 1.6.4 now matches your OS bitness. So if you have a 64 bit Windows you now default get a 64 bit Lazarus. If you still want the 32 bit version (for compatibility issues or otherwise) you can click on "Other" and choose your version.

Almir.Bispo

  • Jr. Member
  • **
  • Posts: 91
  • CSV Comp DB is the Best NoSQL
    • CSV Comp DB (NoSQL)
Re: Copy data to tBufDataSet
« Reply #6 on: September 07, 2017, 02:45:35 pm »
Try using
Code: Pascal  [Select][+][-]
  1. var M:Tmemorystream;
  2. begin
  3. M:=Tmemorystream.create;
  4. Query.savetostream (M);
  5. Buf.loadfromstream (M);
  6. end;
  7.  
(Verify that both methods exist respectively)
http://adltecnologia.blogspot.com.br
CSV Comp DB Developer {Pascal Lover}

cappe

  • Full Member
  • ***
  • Posts: 191
Re: Copy data to tBufDataSet
« Reply #7 on: September 07, 2017, 06:52:31 pm »
Try using
Code: Pascal  [Select][+][-]
  1. var M:Tmemorystream;
  2. begin
  3. M:=Tmemorystream.create;
  4. Query.savetostream (M);
  5. Buf.loadfromstream (M);
  6. end;
  7.  
(Verify that both methods exist respectively)
http://adltecnologia.blogspot.com.br

ZQuery does not have savetostream.

copyfromdataset is slow for many data. Other solutions?
« Last Edit: September 07, 2017, 07:21:28 pm by cappe »

Almir.Bispo

  • Jr. Member
  • **
  • Posts: 91
  • CSV Comp DB is the Best NoSQL
    • CSV Comp DB (NoSQL)
Re: Copy data to tBufDataSet
« Reply #8 on: September 07, 2017, 07:33:04 pm »
look at this:
Code: Pascal  [Select][+][-]
  1.   zquery1.Properties.SaveToStream(M);
  2.  
CSV Comp DB Developer {Pascal Lover}

cappe

  • Full Member
  • ***
  • Posts: 191
Re: Copy data to tBufDataSet
« Reply #9 on: September 08, 2017, 07:40:19 am »
look at this:
Code: Pascal  [Select][+][-]
  1.   zquery1.Properties.SaveToStream(M);
  2.  

But in BufDataSet.loadfromstream I get an error "EDataBaseError" The data-stream format is not recognized.
How do I fix it?

 

TinyPortal © 2005-2018