Transferring a Dataset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Dataset on my PC and I need to transmit it to a Pocket PC over the network. What is best way to accomplish this?

All my communications is done with sockets. I do not want to use Web Services. I will have SQL Server CE running on the Pocket PC but I won't have SQL Server running on the PC. The Dataset could be fairly large, 500k-1M in size when serialized to XML.

Any insight would be greatly appreciated. Thanks in advance!
 
Jason:

How does SQL Ce fit in then? Are you looking to do something like grab the
XML file from the desktop, deserialize it and then overwrite the CE database
each time? Or do you need the data to flow in both directions? In my
experience, you don't really deal with SQL Ce much anyway if you are using
it...you mainly use datasets and it's entirely feasible to have a scenario
where you use CE to load the data and then store it at the end of a session
but not touch it in between. You can deal exclusively with the
datasets/datatables, use ADO.NET's Select/Compute etc to manipulate data.
Basically what I'm getting at is that you can open an XML file and use it to
creata a dataset. You can do what you will with the dataset and then write
it back, moving it when necessary without getting CE involved. CE can be
very convenient, but if you aren' t using the server component, replication
isn't going to be an convenience.

Web services is a great way but you indicated you don't want to do this. Is
ActiveSnyc an option for you or is Sockets the only way you're going to
communicate? If so, it's really not that much different than dealing with
files other than serialization and deserialization of the streams That's
potentially a good amount of data though, so the connection scenario is
important to know.
Jason M said:
I have a Dataset on my PC and I need to transmit it to a Pocket PC over
the network. What is best way to accomplish this?
All my communications is done with sockets. I do not want to use Web
Services. I will have SQL Server CE running on the Pocket PC but I won't
have SQL Server running on the PC. The Dataset could be fairly large,
500k-1M in size when serialized to XML.
 
1MB is not that big, you should be able to use DataSet.ReadXml().
It would take 20-30 seconds to load on PXA255-400 MHz device provided you
have schema in the DataSet or in XML file.
You can minimize XML size and reduce loading time by remapping columns to
attributes and by getting rid of nested relations if you have any.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Thread-Topic: Transferring a Dataset
thread-index: AcQiQKyr9iY4/nLzTYaS6YQShbwK3A==
X-WN-Post: microsoft.public.dotnet.framework.compactframework
From: "=?Utf-8?B?SmFzb24gTQ==?=" <[email protected]>
Subject: Transferring a Dataset
Date: Wed, 14 Apr 2004 09:51:04 -0700
Lines: 5
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.compactframework
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.compactframework:50956
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

I have a Dataset on my PC and I need to transmit it to a Pocket PC over
the network. What is best way to accomplish this?

All my communications is done with sockets. I do not want to use Web
Services. I will have SQL Server CE running on the Pocket PC but I won't
have SQL Server running on the PC. The Dataset could be fairly large,
500k-1M in size when serialized to XML.

Any insight would be greatly appreciated. Thanks in advance!
 
I would suspect the you're not handling NetworkStream correctly, so
DataSet.ReadXml() could not read any data.
The best way to go is to figure out how to get file (any file) from PC to
the device intact and add DataSet code as soon as it works.

If I understand correctly, you're using sockets to get your file, right?
You do have other options besides that. You can:

1. Puts a file on PC's shared folder and load it.
2. Publish file on a web server and get file's content using WebRequest.
3. Use Active Sync to transfer the file to the device.

As to memory stream, this should do it:

DataSet ds = new DataSet();
ds.ReadXml( "FileNameHere" );
MemoryStream ms = new MemoryStream();
ds.WriteXml (new XmlTextWriter(ms, Encoding.UTF8),
XmlWriteMode.WriteSchema);
ms.Seek( 0, SeekOrigin.Begin );
DataSet ds1 = new DataSet();
ds1.ReadXml ( new XmlTextReader(ms));

Best regards,

Ilya

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

--------------------
Thread-Topic: Transferring a Dataset
thread-index: AcQjDg/WJqOfpTtgTdWn1gXoNbxf/w==
X-WN-Post: microsoft.public.dotnet.framework.compactframework
From: "=?Utf-8?B?SmFzb2luIE0=?=" <[email protected]>
References: <[email protected]>
Subject: RE: Transferring a Dataset
Date: Thu, 15 Apr 2004 10:21:17 -0700
Lines: 28
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.compactframework
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.compactframework:51047
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Thank you for your help and quick responses.

I was going to use SQL Server CE because it was already on the device for
another project but I can see that it's not really required.

I'm running into problems trying to serialize my DataSet through a
NetworkStream. The source is a PC and the target is a PocketPC. I would
keep getting I XML exceptions on Line 1, Position 1 of "The data at the
root level is invalid.". I rewrote a portion of it to use a MemoryStream
and bypass all the socket stuff but I still get the same problem. I've
pasted the code below.

I can't understand what is going on. I've done searches for this problem
and only turned up one potential from a Google newsgroup: XmlTextReader
decoding issue. I've taken care of that, I believe, although it doesn't
seem to make much difference.

Any thoughts would be greatly appreciated.


DataSet ds = new DataSet();
ds.ReadXml( @"C:\library.xml" );

MemoryStream ms = new MemoryStream();
XmlTextWriter tempwriter = new XmlTextWriter( ms, Encoding.UTF8 );
ds.WriteXml( tempwriter, XmlWriteMode.WriteSchema );

ms.Seek( 0, SeekOrigin.Begin );

NameTable nt = new NameTable();
XmlNamespaceManager nsmanager = new XmlNamespaceManager(nt);
XmlParserContext context = new
XmlParserContext(nt,nsmanager,null,XmlSpace.None,System.Text.Encoding.UTF8);
XmlTextReader xmlreader = new XmlTextReader(
ms,XmlNodeType.Document,context);

DataSet dsIn = new DataSet();
dsIn.ReadXml( ms, XmlReadMode.ReadSchema);
 
Back
Top