DataSet.WriteXml()

  • Thread starter Thread starter Steve B.
  • Start date Start date
S

Steve B.

Hi,

I'm using the WriteXml method of the dataset to transport data between
distributed applications.

I'd like to use both XmlWriteMode.DiffGram and XmlWriteMode.WriteSchema in
order to package updates of rows and the schema of the dataset.

However, I use something like :

myDs.Write(myStream, XmlWriteMode.DiffGram |XmlWriteMode.WriteSchema);

It does not work, only the diffgram is included in the outputed xml.

I'd like to avoid transporting both a schema file and a data file.

Do you have any idea how I can reach my goal ?

Thanks,
Steve
 
Steve B. said:
Hi,

I'm using the WriteXml method of the dataset to transport data between
distributed applications.

I'd like to use both XmlWriteMode.DiffGram and XmlWriteMode.WriteSchema in
order to package updates of rows and the schema of the dataset.

However, I use something like :

myDs.Write(myStream, XmlWriteMode.DiffGram |XmlWriteMode.WriteSchema);

It does not work, only the diffgram is included in the outputed xml.

I'd like to avoid transporting both a schema file and a data file.

Do you have any idea how I can reach my goal ?

I can't see that it makes any sense.

To have a diff you have to have something to diff it against.

This means that you must always start with a complete object and you can
send the schema with that.
 
The goal is to track any changes made in dataset in the client application.
We use a home made mecanism for transporting the DataSet between clients and
the server.
This mecanism is generic and does not care about type of the dataset.

So when the client app send a dataset, I use
myDataset.ReadXml(myRawDataSet). If myRawDataSet is made with
XmlWriteMode.WriteSchema, the MyDataSet instance is exactly what I want (but
w/o diff).
If I use XmlWriteMode.DiffGram, the schema is not shipped, and when the
dataset read the xml content, it does not know the schema (column types,
tables name, etc...) and the dataset is not correct for the business objets
..

For example, I have in the client App : OrderItemsDataset which has one
table : OrderItemsDataSet:OrderItems (Id : int identity, productName :
string)

When I transfert the dataset to the server w/o the schema but using
DiffGram, after reading the xml, the result dataset does not have any table.
When I transfert the dataset to the server w/o the schema and w/o the
diffgram, after reading the xml, the result dataset has changed all types to
string (which is correct, since there is no way for the dataset to "guess"
the datatype of the columns).

The transport mecanism is build to work with any dataset.
The client layers of the application can do a DataSet result =
myObj.Send(myDataSet);

On the server, each request are handled by the same object, which
reconstruct the dataset from a byte array.

Thanks,
Hope that's clearer
Steve
 
I understand what you are trying to do now but I think that you have gone
about it the wrong way.

Perhaps you should just leave it as XML in the transport and defer
conversion to dataset to somewhere else in your app that knows what it is.

Even if you could achieve what you are trying to do it seems a bit odd to
want to continually send a schema that may well be bigger than the diff.

Another idea is to just cache all the schemas in the server so they only
need to be sent once. There is an XmlSchemaCollection for this purpose
although I don't know if it works directly with DataSet
 
Thanks for your advises.

In order to keep some generics mecanisms as clean as possible, I'll delegate
the instanciating of the dataset to the business objects.
The transport mecanism will query the business object for a DataSet type or
a DataSet instance. The business object will rely on a "verb" transmitted
and it will be able to choose on the server the right xsd file or the right
DataSet type.
In both cases, the dataset will be well constructed by the schema, so the
diffgram will be applied successfully.

Thanks for the help,
Steve
 
Back
Top