Using client datasets with zlib

I have written a small class to compress and uncompress client data sets. I 
can get the compression TCTableData.Assign method to work but the 
decompression TCTableData.AssignTo method does not work in Delphi 7. Can 
anyone tell me why it does not work? It must work with Delphi 7. I have 
listed the code below:

type TCTableData = class   // Compressed table data class
  private
    fdata : TByteDynArray;

  public
    procedure Assign(ds : TDataSet);
    procedure AssignTo(cds  : TClientDataSet);

    property Data : TByteDynArray read fdata write fdata;
  end;


procedure TCTableData.Assign(ds : TDataSet);

// Assigns a dataset to the current compressed table data object

  var mstream  : TMemoryStream;
      cstream  : TCompressionStream;
      cds      : TClientDataSet;
      i        : Integer;

begin
  // Assign input dataset to memory dataset cds
  cds := TClientDataSet.Create(nil);
  cds.FieldDefs.Assign(ds.FieldDefs);
  cds.CreateDataSet;
  ds.First;
  while not ds.Eof do
  begin
    cds.Append;
    for i := 0 to ds.FieldCount-1 do
      cds.Fields[i].Value := ds.Fields[i].Value;
    cds.Post;
    ds.Next;
  end;
  mstream := TMemoryStream.Create;
  cstream := TCompressionStream.Create(clDefault,mstream);
  // Compress and write memory dataset to memory stream
  cds.SaveToStream(cstream);
  cstream.free;
  // Copy compressed data stream to byte array
  SetLength(fdata,mstream.Size);
  mstream.Position := 0;
  mstream.Read(fdata[1],mstream.size);
  mstream.free;
  cds.free;
end;


procedure TCTableData.AssignTo(cds  : TClientDataSet);

// Recreates a client data set from the current compressed table data

  var dstream : TDecompressionStream;
      mstream : TMemoryStream;
      buff    : TByteDynArray;
      size    : Integer;

begin
  mstream := TMemoryStream.Create;
  // Copy compressed table data to memory stream
  mstream.Write(fdata[1],Length(fdata));
  mstream.Position := 0;
  dstream := TDecompressionStream.Create(mstream);
  // Uncompress table data and initialize client data set
  SetLength(buff,3*Length(fdata));
  size := dstream.Read(buff[1],Length(fdata));
  mstream.free;

  mstream := TMemoryStream.Create;
  mstream.Write(buff[1],size);
  mstream.Position := 0;
  cds.LoadFromStream(mstream);
  mstream.free;
  Finalize(buff);
  dstream.free;
end;



Pier
0
Pier
4/10/2015 2:16:59 PM
embarcadero.delphi.dbexpress 764 articles. 0 followers. Follow

0 Replies
1078 Views

Similar Articles

[PageSpeed] 19

Reply:

Similar Artilces:

To use or not to use Delphi
Sadly, it seems to me that there is a sort of race between the two threads, for and against using Delphi in new projects, with more or less the same users posting in both threads. Arguments are fiercely debated in both camps. Borland had their own vision. As a community, now that Delphi has changed ownership I believe we should try to be more consistent, more clear, and more articulate in what we expect from Embercadero in terms of Delphi. We can contribute to keeping Delphi alive and moving in the right direction. "Laurent Cocea" schrieb: > Sadly, it seems to me that there is a sort of race ... <snip> Some people go fishing, some go to the movies, some like to take long walks on the beach, and then some like to type their fingers bloody discussing totally irrelevant issues on public Newsgroups. And my wife likes to watch soap operas and follow posts from a forum where new-baked parents are discussing their kids-issues. Everyone needs a hobby :-) Regards, Danijel Laurent Cocea wrote: > Sadly, it seems to me that there is a sort of race between the two > threads They're essentially the same thread with a little more trolling in one than the other. Lots of free time over the holidays and all. I think the discussion in general is a good thing, though. Help remind people why a tool like Delphi is worth while, and maybe even shed some light on some of the things that still need attention. I still learn about ...

How to create EXCEL file using dataset and stored it on Client's machine using ASP.Net 2.0 and C#?
 Hello,I need to store large number of data in excel sheet so that my clients can view thid data in excel sheet, as the showing this data i.e. almost 15000 rows in the grid is highly impossible, also lot of memory will be consume by this on server. Hnec my approach toward this issue is to save this data directly in the excel template and then either display it or whatever client will choose. First question - Is it possible to generate EXCEL sheet (in a specific column format) from DataSet at runtime?2) How this process should run faster as lot of data will be fetched by the user? R...

SMART Clients using delphi 2006
"SMART Clients" is the future of enterprise software... It is based on Three tier architecture using Web Services... With codegear is so easy develop this kind of software using TSOAPDataModule, TSoapConnection, etc... How much developers are building "SMART Clients" with Delphi 2006 or 2007? Hi! > {quote:title=Juan Carlos Porras Boada wrote:}{quote} > "SMART Clients" is the future of enterprise software... For most of my clients this future is past... > It is based on Three tier architecture using Web Services... > With codegear is...

When to use class? When to use dataset?
We can seperate data layer from presentation layer by using class or dataset in .net 2.0. For example, in an online order system, shall I create a Order class to manage data in database? Or use dataset to manage data? When is better to use class? and, when to use dataset? Thanks a lot!  You can have a typed dtaset to hold all your order details. For doing any manipulation or something you can handle it in your class.  Regards,Lavanya.  You use class if you use a lot of the same functionality over and over again. For instance, you can use a class to retrieve fields from t...

Serving datasets to (non-Delphi) .Net client
I would be grateful for some advice on the best way to design a Delphi web service to inter-operate with a non-Delphi .Net client. The plan is to use RAD Studio 2007 to write a SOAP server to transfer datasets to and from a remote .Net client. [The client end is part of a web site being constructed by another party.] The datasets will contain records with both simple data types and BLOBs. My own preference would be to write the SOAP server as a native WIN32 application but my impression is that doing so would require a large amount of custom serialization code to be written...

Password Encryption through Open Client using Delphi
I am going to develop a client application using Delphi 6 Enterprise Edition to access Sybase using Open Client with password encryption feature. I have read passages on how to do password encryption through Open Client. However, it looked like C code. Can anyone enlighten me on how and where to put the password encryption codes in my Delphi program. I am quite sure it should be somewhere around the database component property. But I don't know what exactly to do. Thanks for your help. ...

Using Sharepoint client objects from Delphi win32 fails
Hi, Really nice if someone could help use with this .NET assembly access problem! We have a problem of accessing Sharepoint Client objects from our win32 Delphi application (Document management), developed in Delphi XE. We have built a .NET COM assembly that encapsulates the Sharepoint Client objects and we generate a pascal TLB from this, our .NET assembly. Calls that are not routed to the Sharepoint Client objects work, but immediatelly when trying to get access to Sharepoint Client Objects, through our .NET COM assembly there seems to be a exception loop started within the Sharepoi ...

Delphi 2010 connection to AS/400 iSeries using dbexpress
I have tried several times to use the dbexpress drivers for connection to an iSeries V5/R4. I have downloaded the files from www.sawatzki.de and tried to run the test programs, but every time I run up my application I get an unknown driver CA400 error. I try changing the driver name and connections in the dbconnections.ini and dbxdrivers.ini so that it uses AS400 but this puts a unit into my project which I don't have. I gave up on this project due to lack of time and did the whole thing using dbGo and ADOConnections etc which got my project running in about 5 mins using a odbc connection...

Using Delphi Rest Client Library in IW application
Hello! I need to authenticate against REST server in IW application. I successfully did this job in VCL application using the following code {code} procedure TForm1.GetAccessToken; var AuthForm: Tfrm_OAuthWebForm; begin AuthForm := Tfrm_OAuthWebForm.Create(nil); try AuthForm.OnAfterRedirect := AuthAfterRedirectToken; OAuth2Authenticator1.ResponseType := TOAuth2ResponseType.rtToken; AuthForm.ShowModalWithURL(OAuth2Authenticator1.AuthorizationRequestURI); finally AuthForm.Free; end; end; {code} How to do it in IW? There is not enough information to provide a full answer. The Rest technology is non-visual, which means it can be implemented, through code, in any project. For an Intraweb project you could put any existing code you have into the UserSession and then call it from wherever you need it. Without knowing what Tfrm_OAuthWebForm contains your question cannot be fully answered. I am assuming that you have your actual Rest code there. You would have to strip that code of any interface interaction, or replace it with code relative to the IW project. Hello, Daniel! > {quote:title=Daniel Fields wrote:}{quote} > There is not enough information to provide a full answer. The Rest technology is non-visual, which means it can be implemented, through code, in any project. For an Intraweb project you could put any existing code you have into the UserSession and then call it from wherever you need it. > >...

Anyone using Delphi clients with Python socket servers?
Hi, Just wondering if anyone is using Delphi clients (indy or synapse) with Python based servers using threads or select from a single process. I have been playing around with Python as the server because its fairly similar to Delphi and runs on every OS. I have made a CRLF based server and a Synapse based client for sending and receiving popup notifications. So far the combo is great, but I am really wondering if anyone has done anything with sending streams(files or other binary data) from delphi to a Python server and how it was handled. -- Tony Caduto AM Software Design http:/...

Any way to use REST client in older versions of Delphi?
The REST components were added by EMBT into XE5. I would like to know if there are third party components to use REST in earlier versions like Delphi 6.0, Delphi 2009 or XE4. I need to access the Amazon.com cloud which uses REST and seems to mostly be for Java or C# programming. Thanks. ...

Can Non-.NET Web Service Clients Use Datasets?
If a .NET-written web serice returns a dataset, can a web service not written in .NET use that dataset? If not, what should be returned? thanks in advance, Geoff I would return a string (in xml format possibly) - you could probably just return DataSet.ToXML() as the return value How about creating an object to represent each row in the dataset and then putting it into an array?...

Problem Deploying Delphi 2010 Application using dbExpress and SQL2000
Dear All, I am deploying an application written in Delphi 2010 using dbExpress to connect to my SQL2000 server. Somehow I keep getting DBX Error: Driver could not be properly initialized. Client library may be missing, not installed properly, or of the wrong version. The program works on a machine which I have previously installed and then uninstalled a trial version of Delphi 2010, but failed to work on a machine that never installed Delphi on. Both machine has "SQL Native Client installed". I have purposely renamed the connection name in my dbxconnections.ini file an...

client dataset > 66 fields (columns) (delphi XE) [Edit]
Is there a limit on the number of fields / columns that can be set up in a client dataset? Answer in this case a very red-faced 'No' but there was a very well hidden SQL change Forum Admin - please delete this !! Edited by: Roy Sharp on Nov 9, 2010 9:21 AM ...

Deployment of Delphi 2009 application using dbExpress and Interbase 7.5.1
Environment: Windows 2003 Server, gds32.dll installed in system directory, dbxint.dll in application folder Application is just an empty Form with TSQLConnection, configured for Interbase driver. No runtime packages used, no logic, just the connection component with Connected = False Result: Application process ends immediately after startup, no form displayed Is there something else which needs to be deployed with Delphi 2009 applications using Interbase and dbExpress? Mike p.s. I have checked (on development workstation) what happens if the folder with dbxconnectio...

Can I use StoredProcedures using DataSet
I am using an application where the concept goes with dataset.Now I just want to know if i can use stored procedures in dataset,dataadapter etc with sqlserver 7.0.Suggestions will be appreciated.Regardslitesh80. Sure...Set the CommandType to StoredProcedure and the CommandText to the name of the proc. Thank you Its working fine...Regardslitesh80. ok its working fine.But is there any performance improvement by using the stored procedures.If so how do they?Regardslitesh80. Hi, you can refer to this guide from MSDNAlvin ChooiMicrosoft ASP.NET™ Enthusiast v1.1 / v2.0, Malaysia Blog : htt...

What is DataSet.xsd? How is DataSet.xsd used?
Hello, I am trying to understand what DataSet.xsd is and how is works.    I searched the forum, but I could not find documentations that explain it.   I am looking at the club web site now and I do not understand how DataSet.xsd is used in the web site.Suggestions would be appreciated.Jim   Hi jim,If you have used DataSet Typed then you would have <custom>.xsd. In your case DataSet.xsd. It is very useful to Crystal Reports and other stuffs.Good Coding!Javier Luna http://guydotnetxmlwebservices.blogspot.com/ from Villa El Salvador for world! &...

Using typed dataset or using XPath.
Hai Guys,        How can i use the statement shown below with typed dataset or using XPath. Select (firstname+Lastname) as Name From Emp   Thanks in Advance Justin You can add a query to the TableAdapter of the typed dataset: right click the typed dataset in Solution Explorer-> choose View Designer->right click the  TableAdapter -> choose add query->choose Use SQL Statement as the command type ->finish the wizard. Welcome to my SQL/ASPNET forum for Chinese http://51up.org/bbs/forumdisplay.php?fid=38 Hi,  &nb...

Using Delphi 7 and Delphi 2010
I had a project in Delphi 7. I worked on it in Delphi 2010. When I try to open the .dpr again in Delphi 7, the IDE toolbar widens across both monitors, and Delphi 7 locks up. It appears that Delphi 2010 modifies the .dpr in a way that makes Delphi 7 unable to open it again. All my forms & units appear to open fine in D7 after D2010, except for the warnings on the ExplicitHeight and ExplicitWidth properties being missing... I can easily recreate the .dpr, but is this expected behavior? Thanks. Tom Field wrote: > I had a project in Delphi 7. > > I worked o...

Client Options not used by Windows Client
Hallo, with consoleOne configured Client settings at PO Level are ignored by Windows Clients When does the Windows GroupWise Clients get central configured Settings? GW7 on OES/Linux Gordon, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been resolved? If not, you might try one of the following options: - Do a search of our knowledgebase at http://support.novell.com/search/kb_index.jsp - Check all of the other support tools and options available at http://su...

Retrieving data from database in client asp.net using webservice <webmethod > as dataset
I have problem that i have made webservice in which i want to create function as dataset in which i retrieve a data from database select columns from table where = some condition .and this condtion i want to give client side through dropdownlist and bound that data into client label.HOW CAN I ACHIEVE THIS.  Hi.Using DataSets as returned object from web services can work only between two .Net applications, this is because DataSet cannot be serialized over SOAP.For that metter, a Javascript runs on the client is definatly not a .Net application.I suggest you'd return a typed objects...

Has anyone successfully used a Delphi web service client against an ENCRYPTED WCF web service server?
Has anyone successfully used a Delphi web service client against an ENCRYPTED WCF web service server? Which is to say, of course, that the URL would be starting with https. Anyone? ...

Error: "receiver invalid column lenght from bcp client" Bulk copy from Oracle Database to SqlServer database using Dataset
I want to export data from Oracle database tables to Sqlserver database tables. using VS.NET 2005(Windows application). I have created same table structure in SQL server to export the data using Dataset.  I am getting error : "receiver invalid column lenght from bcp client" " bulkcopy.WriteToServer(ds1.Tables[0]);private void button3_Click(object sender, EventArgs e) {string constr1 = "data Source=oracle;user id=scott;password=tiger";OracleConnection conn2 = new OracleConnection(constr1); conn2.Open(); string sql1 = "select * from " + textBox4....

How design a COM using Delphi and Using in PB7?
I need some component, So, we want using DELPHI5 to develop a COM or Activex. What type of knowege or Skill I must know it. Can anyone tell us? from DRAOGN Can you explain what type of component you want to create? You may not need to a) build your own, or b) use Delphi. If the component should be used from within a PB application, you ought to use PB to develop it unless it is something that PB does not let you do. regards, Bill DRAGON wrote: > I need some component, So, we want using DELPHI5 to develop a COM or > Activex. > What type of knowege or Skill I ...

Web resources about - Using client datasets with zlib - embarcadero.delphi.dbexpress

UAH satellite temperature dataset - Wikipedia, the free encyclopedia
The UAH satellite temperature dataset , developed at the University of Alabama in Huntsville , attempts to infer the temperature of the atmosphere ...

Data : Where can I get large datasets open to the public?
Answer (1 of 91): Here's the ones I've found most useful: CrunchBase, US Census, Google Public Data, Infochimps, Timetric, Factual, Freebase, ...

YouTube - Hans Rosling: Let my dataset change your mindset
Hochgeladen am 31.08.2009 http://www.ted.com Talking at the US State Department this summer, Hans Rosling uses his fascinating data-bubble software ...

The Mindset, Skillset, Dataset Approach to Social Media
... Social media is comprised primarily of unstructured data, which is difficult to analyze. A new approach called Mindset, Skillset, Dataset can ...

Sending large datasets to Amazon? Use the Post Office
Amazon has introduced a new method to move large amounts of data to and from …

Yahoo Releases the Largest-ever Machine Learning Dataset for Researchers
Yahoo is announcing the public release of the largest-ever machine learning dataset to the research community.

IDG Contributor Network: Are datasets truly anonymized? Two well-suited researchers are going to find ...
With little fanfare or formality, Adam Smith , associate professor of computer science and engineering in Penn State's School of Electrical Engineering ...

House GOP looks to shed light on EPA secret datasets
House Republicans have introduced a bill that would block the Environmental Protection Agency from crafting regulations based on “secret” scientific ...

Google Making It Easier to Transfer Huge Datasets on the Cloud
... Cloud Import services are now in preview mode, but could later be available on a widespread basis to help enterprises move their large datasets ...

Environmental datasets, reverse auction legislation and military email
News and notes from around the federal IT community. The White House's Data.gov has added five datasets to the Ecosystem Vulnerability theme ...

Resources last updated: 2/17/2016 8:35:37 AM