473,804 Members | 2,536 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serializing a dataset

I am serializing a dataset and sending it across a slow socket connection
using the following code. I know I can send binary data across a socket but
when I serialize the dataset it ends up being text and very large. I am
thinking about zipping it but was wondering if maybe there was a better way?

System.Runtime. Serialization.I Formatter f = new
System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er();
System.IO.Memor yStream ms1 = new System.IO.Memor yStream();
f.Serialize(ms1 , DataArg);
this.socket.Sen d(ms1.GetBuffer ());

Regards,
John
Nov 16 '05 #1
4 3434
You serialize the dataset as XML, then zip it. See the zip library at

http://www.icsharpcode.com

I've used, it's great. As you may already know, you can serialize a dataset
to a XML with the function WriteXML(). The zip library can then read the
file and compress it.

The only quirk I found with the zip lib is that is doesn't
compress/decompress MemoryStreams, only FileStreams.

--
kevin aubuchon
www.aubuchon-design.com
"John J. Hughes II" <no@invalid.com > wrote in message
news:eN******** ******@tk2msftn gp13.phx.gbl...
I am serializing a dataset and sending it across a slow socket connection
using the following code. I know I can send binary data across a socket but when I serialize the dataset it ends up being text and very large. I am
thinking about zipping it but was wondering if maybe there was a better way?
System.Runtime. Serialization.I Formatter f = new
System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er();
System.IO.Memor yStream ms1 = new System.IO.Memor yStream();
f.Serialize(ms1 , DataArg);
this.socket.Sen d(ms1.GetBuffer ());

Regards,
John

Nov 16 '05 #2
Kevin,

Well our company does not want our project under the GPL and if I include
that code then I have to if I understand correctly.

As a side note I have found serializing the data makes a smaller footprint
then writing to XML which really makes no sense but that be the case. This
might change if the parameters for the XML write were changed, I did not
look into it that far.

System.Runtime. Serialization.I Formatter f = new
System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er();
System.IO.Memor yStream ms1 = new System.IO.Memor yStream();
f.Serialize(ms1 , DataArg);

System.IO.Memor yStream ms = new System.IO.Memor yStream();
DataArg.dsData. WriteXml(ms);

ms1.Length 23069716
ms.Length 24932130

Regards,
John
Nov 16 '05 #3
One caveat with serializing the dataset is that you remove
compatibility with anything other than a .NET based client/server...
and changing the data format can be annoying. It's usually much better
to save as xml and zip or compress the data somehow.

Nov 16 '05 #4
Johnny,

I can see you point. Currently I am talking to myself so to say ( writing
both ends ) so don't really consider it a problem but will keep that in
mind.

Regards,
John
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1236
by: Mike Peretz | last post by:
I don't know why, but for some reason exception do not serialize correctly when they hold a typed dataset. I have added code to serialize the dataset, but still when it gets to the other appDomain, half of it is missing. Is there a bug with remoting and serializing datasets or typed datasets? I am able to serialize typed datasets with remote methods, but at this point I am worried that I am playing with fire.
0
1734
by: Matt Parker | last post by:
Hi I was wondering if anyone would be able to help me with this problem. I have an annotated schema that I use to query my database and fill a dataset using the sqlxmladapter. The call to query the database is made through a webservice. I have used xsd.exe to create a serializable class based on the schema, that I can pass back through the webservice, but I have a
1
2089
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I created a couple of objects and serializing it into XML based upon the schema works perfectly. The XML / Schema looks something like this:
1
5406
by: Chris | last post by:
I'm having trouble Serializing a System.Data.DataColumn object. When I try to serialize it, I get the following: System.NotSupportedException: Cannot serialize member System.ComponentModel.MarshalByValueComponent.Site of type System.ComponentModel.ISite because it is an interface. I tried a number of workarounds without sucess:
2
3526
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: + More ways to contact me __________________________________________________________________
1
2583
by: Aidan Glendye | last post by:
Hi, I am trying to store various objects within session. Due to the site being hosted in a web farm we are going to have to use either State Server or SQL Server to persist the data in session. All of the objects are classes which inherit from a typed dataset. Looking at MSDN I have found the following two (what I believe to be) relevent statements (from article Object
0
1061
by: MattB | last post by:
I have a dataset that originated as a string (passed from a C++ dll). I de-serialize it, use the data, and then in some cases I will serialize it again to pass as a session variable in my app and then de-serialize it again. This generally works well, but I just hit a problem de-serializing it. I have a vb class set up with commonly used code and have functions to handle serialization and de-serialization. Suddenly, I'm hitting the...
2
1318
by: Doug Eller | last post by:
I am serializing datasets and sending them out to a client application via a web service. My problem is that the associated schema includes all of my connection string, database username and password and SQL info. This is bad. I can think of two ways to deal with this: 1. Parse the data out of the schema before i send it out 2. Encrypt the data My question is......is there a better way?
4
3293
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have been experimenting with how to properly store objects into persistent application settings in user.config. I have read everything I could on MSDN (and elsewhere) and I have successfully stored objects of type String, DateTime, and ArrayList, for example. So I then tried an unbound DataGridView but it serialized with a null value. I tried the DataSource of the DataGridView; also null. I was going to try DataGridViewRowCollection,...
0
10594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.