When passing datasets around via webservices we've had some problems with the size of the resulting xml. The following code will compress the dataset and turn it into a byte(). Note that you need to close the streams after calling WriteXml otherwise you'll get a "unexpected end of file" style exception when you try to load back into your dataset.
Dim ms As New IO.MemoryStreamDim cs As New IO.Compression.GZipStream(ms, IO.Compression.CompressionMode.Compress, False)results.WriteXml(cs)cs.Close()ms.Close()Dim bytes As Byte() = ms.ToArray
Heres the corresponding decompression code for the server component.
Dim results As New DataSetDim ms As New IO.MemoryStream(_Args.Results)Dim cs As New IO.Compression.GZipStream(ms, IO.Compression.CompressionMode.Decompress, False)results.ReadXml(cs)cs.Close()ms.Close()
dasBlog theme by Mads Kristensen
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.