VB Code:
Public Function DataSetToString(ByRef ds As DataSet) As String
Dim ms As MemoryStream = New MemoryStream()
Dim bf As New BinaryFormatter()
bf.Serialize(ms, ds)
ms.Position = 0
Dim sr As Byte()
sr = ms.ToArray()
Return Encoding.ASCII.GetString(sr) 'or unicode, is the same
End Function
Public Function StringToDataSet(ByVal data As String) As DataSet
Dim ms As New IO.MemoryStream()
Dim sw As New IO.StreamWriter(ms)
Dim bf As New BinaryFormatter()
sw.Write(data)
sw.Flush()
ms.Position = 0
Dim ds As New DataSet()
ms.Position = 0
ds = bf.Deserialize(ms)
Return ds
End Function
Those are the functions I used to serialize and deserialize the DataSet. One in the server, the other in the client. The two Encoding are: one in these functions, the other when I send the string through the network.