G
Guest
I have an application that saves a bunch of data in XML files that come from
typed datasets.
So, I have something like this:
MyTypedDs myds;
//.... When the user wants to save the data
myds.WriteXML(thefilename,XMLWriteMode.WriteSchema);
Later on, when he wants to open a saved file,
myds=new (MyTypedDs);
myds.ReadXML(thefilename,XMLReadMode.ReadSchema);
Great. So far, so good.
Now, some fields have been added to the records. The tables in the dataset
have some additional columns. I want to be able to open up the old files
that have been previously saved, and if the file is from the old format,
convert it to the new format, filling in default values for missing fields.
TypedDSV1 myversion1ds;
TypedDSV2 myversion2ds;
DataSet myds;
//When opening a file.
myds.ReadXML(thefilename,XMLReadMode.ReadSchema)
if (the schema from the file matches version1)
{myversion1ds=(TypedDSV1)myds;
Convertv1tov2(myversion1ds,myversion2ds);
}
else if (the schema from the file matches version 2)
{
myversion2ds=(TypedDSV2)myds;
}
else return retvals.Schemadoesntmatch;
So, is there a very easy way to write the (the schema from the file matches
version 2) function?
typed datasets.
So, I have something like this:
MyTypedDs myds;
//.... When the user wants to save the data
myds.WriteXML(thefilename,XMLWriteMode.WriteSchema);
Later on, when he wants to open a saved file,
myds=new (MyTypedDs);
myds.ReadXML(thefilename,XMLReadMode.ReadSchema);
Great. So far, so good.
Now, some fields have been added to the records. The tables in the dataset
have some additional columns. I want to be able to open up the old files
that have been previously saved, and if the file is from the old format,
convert it to the new format, filling in default values for missing fields.
TypedDSV1 myversion1ds;
TypedDSV2 myversion2ds;
DataSet myds;
//When opening a file.
myds.ReadXML(thefilename,XMLReadMode.ReadSchema)
if (the schema from the file matches version1)
{myversion1ds=(TypedDSV1)myds;
Convertv1tov2(myversion1ds,myversion2ds);
}
else if (the schema from the file matches version 2)
{
myversion2ds=(TypedDSV2)myds;
}
else return retvals.Schemadoesntmatch;
So, is there a very easy way to write the (the schema from the file matches
version 2) function?