Binary format made DataSet become more intelligent in ADO.NET 2.0
Even though we all like DataSet; as Serialization of DataSet is more expensive in ASP.NET 1.x, most of us had put lot of thought before using it!
From ADO.NET 2.0 on, we don’t need to worry that much! MS put lot off effort on improving performance on Serialization in DataSet.
In ADO.NET 1.x, the Serialization of DataSet happens in XML format. Even in ADO.NET 2.0 by default it happens in XML format. But there is an option to change the Serialization format to Binary using the property called RemotingFormat (of SerializationFormat.Binary). The Binary format improves performance a lot!
A Simple Example on How to:
DataSet DS = (DataSet)DataGridView1.DataBind; System.Runtime.Serialization.Formatters.Binary.BinaryFormatter Frmt = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
using (FileStream fs = new FileStream("c:\\SampleOne.bin", FileMode.CreateNew))
{
DS.RemotingFormat = SerializationFormat.Binary;
// Other wise you can go for SerilaizationFormat.XML
Frmt.Serialize(fs, DS);
}
Hope it helps you!