DiffGram DataSet Issue

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 &amp; 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 &amp; 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)
 
I

Ilya Tumanov [MS]

Michael,

You can load diffgram only if you have schema loaded into the DataSet.
Save schema to separate file and load it before loading diffgram or create
schema programmatically.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
 
M

Michael McGuire

That works! Thank you so much!

This doesn't seem to be a requirement in the normal framework because this
code works in a normal Windows application. It's good to know.

Thanks again!

Mike


"Ilya Tumanov [MS]" said:
Michael,

You can load diffgram only if you have schema loaded into the DataSet.
Save schema to separate file and load it before loading diffgram or create
schema programmatically.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Michael McGuire" <[email protected]>
Subject: DiffGram DataSet Issue
Date: Thu, 25 Mar 2004 14:45:16 -0700
Lines: 139
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: ip68-106-229-28.ph.ph.cox.net 68.106.229.28
Path:
cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08
phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.compactframework:49515
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

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 &amp; 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 &amp; 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)
 
I

Ilya Tumanov [MS]

Actually, it is a requirement on "normal" framework.
You probably using typed DataSet which got "embedded" schema.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
From: "Michael McGuire" <[email protected]>
References: <[email protected]>
Subject: Re: DiffGram DataSet Issue
Date: Thu, 25 Mar 2004 18:41:23 -0700
Lines: 197
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: ip68-106-229-28.ph.ph.cox.net 68.106.229.28
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.compactframework:49537
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

That works! Thank you so much!

This doesn't seem to be a requirement in the normal framework because this
code works in a normal Windows application. It's good to know.

Thanks again!

Mike


"Ilya Tumanov [MS]" said:
Michael,

You can load diffgram only if you have schema loaded into the DataSet.
Save schema to separate file and load it before loading diffgram or create
schema programmatically.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Michael McGuire" <[email protected]>
Subject: DiffGram DataSet Issue
Date: Thu, 25 Mar 2004 14:45:16 -0700
Lines: 139
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: ip68-106-229-28.ph.ph.cox.net 68.106.229.28
Path:
cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08 from
a to
have empty.
If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top