Visual C # 2008 Database Application Examples
I only have a few weeks of programming with vC # (2008) and I am trying to create an application (winforms) and I have the following problem ... I need my application to work and without connecting to the mssql database, it sounds like a piece of cake for our friend DataSet? I can save the data as XML or binaries until I can get to the database and the DataSet will magically sync; everything without disturbing the user. The problem is ... several books I've read just mention this logic as a fairy tale, but don't give any practical example of how to do this, can you point me to one example / demo / whatever I can to read or download an application with (equal or) similar logic?
a source to share
Serialization should be as simple as:
Binary.BinaryFormatter formatter = new Binary.BinaryFormatter();
DataSet ds = new DataSet();
// populate data set
using (FileStream fs = new FileStream("c:\\dataset.bin", FileMode.CreateNew))
{
ds.RemotingFormat = SerializationFormat.Binary;
formatter.Serialize(fs, ds);
}
to deserialize:
using (FileStream fs = new FileStream("c:\\dataset.bin", FileMode.Open))
{
formatter = new BinaryFormatter();
DataSet ds = (DataSet)formatter.Deserialize(stream);
}
(Rough ... not near the compiler for proper testing)
a source to share
If you are using DataSet you can just use DataSet.WriteXml and DataSet.ReadXml . Or am I missing something?
a source to share