M
Michael McGuire
I am attempting to create a PocketPC 2002 application using the .NET Compact
Framework and Web Services. I have a web service that I connect to from a
mobile client form, and attempt to save the file off as a DiffGram because I
wish to track changes to upload back to the server. However, I seem to have
a problem loading the file back into an empty and new DataSet.
Here is the code I use to save the file out:
StreamWriter stream = null;
XmlTextWriter writer = null;
try
{
stream = new StreamWriter(fileName);
writer = new XmlTextWriter(stream);
// Save out to file
plan.WriteXml(writer, XmlWriteMode.DiffGram);
}
finally
{
if (stream != null)
stream.Close();
}
Here is the results of the GetXml() call to the DataSet just before
persisting:
<NewDataSet>
<PlanDetail>
<CalorieTotal>500</CalorieTotal>
<Description>Eggs, Bacon and Toast!</Description>
<EventTime>2004-03-17T07:00:00.0000000-07:00</EventTime>
<PlanDetailID>2</PlanDetailID>
<PlanID>2</PlanID>
<Title>Breakfast</Title>
<EventDescription>Breakfast</EventDescription>
<Complete>true</Complete>
</PlanDetail>
<PlanDetail>
<CalorieTotal>700</CalorieTotal>
<Description>Peanut Butter & Jelly Sandwhich</Description>
<EventTime>2004-03-17T12:00:00.0000000-07:00</EventTime>
<PlanDetailID>3</PlanDetailID>
<PlanID>2</PlanID>
<Title>Lunch</Title>
<EventDescription>Lunch</EventDescription>
<Complete>false</Complete>
</PlanDetail>
<PlanDetail>
<CalorieTotal>-200</CalorieTotal>
<Description>Thirty Pushups</Description>
<EventTime>2004-03-17T15:00:00.0000000-07:00</EventTime>
<PlanDetailID>4</PlanDetailID>
<PlanID>2</PlanID>
<Title>MidDay Exercise</Title>
<EventDescription>Exercise</EventDescription>
<Complete>true</Complete>
</PlanDetail>
</NewDataSet>
Here is what the file looks like after being persisted (this is what is
looks like on disk):
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1\">
<NewDataSet>
<PlanDetail diffgr:id="PlanDetail1" msdata:rowOrder="0">
<CalorieTotal>500</CalorieTotal>
<Description>Eggs, Bacon and Toast!</Description>
<EventTime>2004-03-17T07:00:00.0000000-07:00</EventTime>
<PlanDetailID>2</PlanDetailID>
<PlanID>2</PlanID>
<Title>Breakfast</Title>
<EventDescription>Breakfast</EventDescription>
<Complete>true</Complete>
</PlanDetail>
<PlanDetail diffgr:id="PlanDetail2" msdata:rowOrder="1">
<CalorieTotal>700</CalorieTotal>
<Description>Peanut Butter & Jelly Sandwhich</Description>
<EventTime>2004-03-17T12:00:00.0000000-07:00</EventTime>
<PlanDetailID>3</PlanDetailID>
<PlanID>2</PlanID>
<Title>Lunch</Title>
<EventDescription>Lunch</EventDescription>
<Complete>false</Complete>
</PlanDetail>
<PlanDetail diffgr:id="PlanDetail3" msdata:rowOrder="2">
<CalorieTotal>-200</CalorieTotal>
<Description>Thirty Pushups</Description>
<EventTime>2004-03-17T15:00:00.0000000-07:00</EventTime>
<PlanDetailID>4</PlanDetailID>
<PlanID>2</PlanID>
<Title>MidDay Exercise</Title>
<EventDescription>Exercise</EventDescription>
<Complete>true</Complete>
</PlanDetail>
</NewDataSet>
</diffgr:diffgram>
Here is the code I use to read in the file:
XmlTextReader reader = null;
StreamReader stream = null;
try
{
stream = new StreamReader(fileName);
reader = new XmlTextReader(stream);
DataSet plan = new DataSet();
plan.ReadXml(reader, XmlReadMode.DiffGram);
return plan;
}
catch (Exception e)
{
return null;
}
finally
{
if (stream != null)
stream.Close();
}
I get no exceptions on reading the dataset, but it is completely empty. If
I do a .GetXml() on the new DataSet it gives me: "<NewDataSet />". There
are no tables, no nothing. This means I am unable to persist the file to
the device and then reload for future updates. Does anyone have any ideas?
Mike McGuire
(e-mail address removed)
Framework and Web Services. I have a web service that I connect to from a
mobile client form, and attempt to save the file off as a DiffGram because I
wish to track changes to upload back to the server. However, I seem to have
a problem loading the file back into an empty and new DataSet.
Here is the code I use to save the file out:
StreamWriter stream = null;
XmlTextWriter writer = null;
try
{
stream = new StreamWriter(fileName);
writer = new XmlTextWriter(stream);
// Save out to file
plan.WriteXml(writer, XmlWriteMode.DiffGram);
}
finally
{
if (stream != null)
stream.Close();
}
Here is the results of the GetXml() call to the DataSet just before
persisting:
<NewDataSet>
<PlanDetail>
<CalorieTotal>500</CalorieTotal>
<Description>Eggs, Bacon and Toast!</Description>
<EventTime>2004-03-17T07:00:00.0000000-07:00</EventTime>
<PlanDetailID>2</PlanDetailID>
<PlanID>2</PlanID>
<Title>Breakfast</Title>
<EventDescription>Breakfast</EventDescription>
<Complete>true</Complete>
</PlanDetail>
<PlanDetail>
<CalorieTotal>700</CalorieTotal>
<Description>Peanut Butter & Jelly Sandwhich</Description>
<EventTime>2004-03-17T12:00:00.0000000-07:00</EventTime>
<PlanDetailID>3</PlanDetailID>
<PlanID>2</PlanID>
<Title>Lunch</Title>
<EventDescription>Lunch</EventDescription>
<Complete>false</Complete>
</PlanDetail>
<PlanDetail>
<CalorieTotal>-200</CalorieTotal>
<Description>Thirty Pushups</Description>
<EventTime>2004-03-17T15:00:00.0000000-07:00</EventTime>
<PlanDetailID>4</PlanDetailID>
<PlanID>2</PlanID>
<Title>MidDay Exercise</Title>
<EventDescription>Exercise</EventDescription>
<Complete>true</Complete>
</PlanDetail>
</NewDataSet>
Here is what the file looks like after being persisted (this is what is
looks like on disk):
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1\">
<NewDataSet>
<PlanDetail diffgr:id="PlanDetail1" msdata:rowOrder="0">
<CalorieTotal>500</CalorieTotal>
<Description>Eggs, Bacon and Toast!</Description>
<EventTime>2004-03-17T07:00:00.0000000-07:00</EventTime>
<PlanDetailID>2</PlanDetailID>
<PlanID>2</PlanID>
<Title>Breakfast</Title>
<EventDescription>Breakfast</EventDescription>
<Complete>true</Complete>
</PlanDetail>
<PlanDetail diffgr:id="PlanDetail2" msdata:rowOrder="1">
<CalorieTotal>700</CalorieTotal>
<Description>Peanut Butter & Jelly Sandwhich</Description>
<EventTime>2004-03-17T12:00:00.0000000-07:00</EventTime>
<PlanDetailID>3</PlanDetailID>
<PlanID>2</PlanID>
<Title>Lunch</Title>
<EventDescription>Lunch</EventDescription>
<Complete>false</Complete>
</PlanDetail>
<PlanDetail diffgr:id="PlanDetail3" msdata:rowOrder="2">
<CalorieTotal>-200</CalorieTotal>
<Description>Thirty Pushups</Description>
<EventTime>2004-03-17T15:00:00.0000000-07:00</EventTime>
<PlanDetailID>4</PlanDetailID>
<PlanID>2</PlanID>
<Title>MidDay Exercise</Title>
<EventDescription>Exercise</EventDescription>
<Complete>true</Complete>
</PlanDetail>
</NewDataSet>
</diffgr:diffgram>
Here is the code I use to read in the file:
XmlTextReader reader = null;
StreamReader stream = null;
try
{
stream = new StreamReader(fileName);
reader = new XmlTextReader(stream);
DataSet plan = new DataSet();
plan.ReadXml(reader, XmlReadMode.DiffGram);
return plan;
}
catch (Exception e)
{
return null;
}
finally
{
if (stream != null)
stream.Close();
}
I get no exceptions on reading the dataset, but it is completely empty. If
I do a .GetXml() on the new DataSet it gives me: "<NewDataSet />". There
are no tables, no nothing. This means I am unable to persist the file to
the device and then reload for future updates. Does anyone have any ideas?
Mike McGuire
(e-mail address removed)