473,573 Members | 3,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dataset to XML string in Compact Framework

HI,

This all applies to a project in the compact framework (Pocket PC).

I need to convert a dataset object into XML which I will then send out
via TCP.
In a standard app I would do this as follows:

System.IO.Strin gWriter sw = new StringWriter();
ds.WriteXml(sw) ;
string xml = sw.ToString();

However the WriteXml method of compact datasets only supports filenames
and XMLWriters.
I DON'T want to write to a file and then read it in again; it would
kill have the devices resources to do so.

So I've been fumbling with the XMLWriter but can't get any XML out of
it. This is what I have in my device project:

TextWriter tw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(t w);
ds.WriteXml(xtw , XmlWriteMode.Wr iteSchema);
// xtw.Flush();
tw.Write(xml);

Any help is greatly appeciated. I'm also going to need the REVERSE code
as well;
ie. From XML back to a DataSet. Schema needs to be included in both
directions.

Many thanks,
Steven Nagy

Dec 5 '05 #1
6 6522
Hi,
I have the very same escenario, this is the code I use to persists the DS

StreamWriter stream = new StreamWriter( dstFile, false);
XmlTextWriter reader = new XmlTextWriter(s tream);
DataAccess.Orde rsDS.WriteXml( reader, XmlWriteMode.Wr iteSchema);
reader.Close();
stream.Close();

Now, a warning , the file may be large depending of the dataset, that's why
I zip it and then send the zipped file.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Steven Nagy" <le*********@ho tmail.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
HI,

This all applies to a project in the compact framework (Pocket PC).

I need to convert a dataset object into XML which I will then send out
via TCP.
In a standard app I would do this as follows:

System.IO.Strin gWriter sw = new StringWriter();
ds.WriteXml(sw) ;
string xml = sw.ToString();

However the WriteXml method of compact datasets only supports filenames
and XMLWriters.
I DON'T want to write to a file and then read it in again; it would
kill have the devices resources to do so.

So I've been fumbling with the XMLWriter but can't get any XML out of
it. This is what I have in my device project:

TextWriter tw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(t w);
ds.WriteXml(xtw , XmlWriteMode.Wr iteSchema);
// xtw.Flush();
tw.Write(xml);

Any help is greatly appeciated. I'm also going to need the REVERSE code
as well;
ie. From XML back to a DataSet. Schema needs to be included in both
directions.

Many thanks,
Steven Nagy

Dec 5 '05 #2
yeah but thats the problem, I want to avoid using files all together.
Anyway, I got around it. Just needed to tinker with the StringWriter
classes a bit more.

I don't like writing to file because then that means at any given time
there's a copy of the dataset in memory and on disk/memory, taking
twice the space which is a bad thing I think to do on PocketPC.

Thanks anyways.

Dec 7 '05 #3
Hi,


I don't like writing to file because then that means at any given time
there's a copy of the dataset in memory and on disk/memory, taking
twice the space which is a bad thing I think to do on PocketPC.


Well, you now most have two copies in memory of the dataset :) taking twice
the space , how you improved it?
The above solution has been working in an app over 3 years now, not a single
complain or a problem until now.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Dec 7 '05 #4
Hey,

I'm not ditching on your apps or anything! I just think there must be a
better way.

Currently you:
1) Have a (dataset)
2) which you save to a (file)
3) and then read in on a (stream)
4) which you then write to a (string).

Right?
All I'm saying is that wouldn't it be better to:
1) Have a (dataset)
2) which you write directly to a (stream)
3) which you then write to a (string)

Of course when I put it like this, it doesn't seem like such a huge to
have that extra step, however I am guessing that in any PocketPC apps
one should probably minimise ANY steps that speed up the app and reduce
the amount of memory used.
The above solution has been working in an app over 3 years now, not a single
complain or a problem until now.


Its good that your apps are robust, I wasn't complaining about your
app; I've never seen it!

Keep up the discussion, as I am still learning PocketPC stuff and it
all helps.

Cheers,
Steven Nagy

Dec 7 '05 #5
Hi,

"Steven Nagy" <le*********@ho tmail.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Hey,

I'm not ditching on your apps or anything! I just think there must be a
better way.
No offence taken, just trying to help
Currently you:
1) Have a (dataset)
2) which you save to a (file)
2.5) Zip it.
3) and then read in on a (stream)
4) which you then write to a (string)
4) which you then write to a (stream)
Right?
All I'm saying is that wouldn't it be better to:
1) Have a (dataset)
2) which you write directly to a (stream)
3) which you then write to a (string)
It depends of where your critical link is, mine is in the transmition,
usually the data is sent from the field using a cell phone as modem, as you
can imagine this is the most critical part, I need to transfer the least
amount of data possible. That's why the zip step

The other requirement is that I need to store the transferred data for a
couple of days, in case its need to be consulted again or (most of the time)
retransmited , a file for this is super handy, you have the timestamp of
when it was send.
Of course when I put it like this, it doesn't seem like such a huge to
have that extra step, however I am guessing that in any PocketPC apps
one should probably minimise ANY steps that speed up the app and reduce
the amount of memory used.
Yes, indeed but sometimes you have to trade off , like the above case, the
transmition of the data is a one time operation, you better concentrate your
efforts to make the application faster in the diary use.

A VERY GOOD ADVISE: do not use a dataset to store your data, the
boxing/unboxing can kill the performance , use either SQL CE or a custom
class. I improved the overall performance like 300% when I stopped using
dataset in memory to store the data , I'm talking of 3 tables of around 2K
rows each and one with around 10K.

Keep up the discussion, as I am still learning PocketPC stuff and it
all helps.


A very good resource is the compactframewor k group
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Dec 8 '05 #6
Ah now you're making sense to me!

Yes you need to zip it before you send it which means you have no
choice about saving to a file.
In our case, our application runs on a wireless network where the
server is on the same network, and we're not talking about passing
thousands of rows every query.
So for us, saving to a file is no necessary, but definately is in your
case.

Thanks for the advice on the dataset thing. We actually have our own
branded designer classes for that sort of stuff. Datasets are a memory
leech even in the standard framework!

Steven Nagy

Dec 8 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2592
by: Earle Oxner | last post by:
We are developing an application on PocketPC2002 platform and we are trying to make webservice calls using HTTPS. HTTP works fine but HTTPS does not work. The same code which doesn't work on PocketPC, works on the laptop with .NET Framework. I was hoping you could help me with answering some questions: 1. Does HTTPS work for the...
2
2845
by: Duncan | last post by:
I am using the evaluation version of CE.NET 4.1. I had also installed the release version of the Compact Framework. I uninstalled the CE.NET 4.1, and then realized I needed it again and reinstalled it. I also installed all the QFEs. When I tried to reinstall the release Compact Framework, I get a message that it is already installed...
1
2501
by: Asad Khan | last post by:
Hi, I have Visual Studio 2002 Enterprise Architecture Edition. I was wondering if anyone has any information on how I can develop applications for .Net Compact Framework using this IDE. I've heard Visual Studio 2003 ships with the functionality for .Net Compact Framework development. But right now I have Visual Studio 2002. Is there anything I...
4
7472
by: Brian Keating | last post by:
wonder if anyone can help me here, i've a framework 1.1 dataset which i serialize in framework 1.1 and deserialize in framework 2.0. This is fine, problem is that i want to modify some of the records in framework 2.0 and serialize the data so framework 1.1 can deserialize it and do what it required. Is this possible?
1
2012
by: cindy | last post by:
Get data into datatable, add to dataset dsSearch " Get data into datatable, add to dataset dsSearch Using In-Memory SQL Engine join the tables and select the filenames from the join, add to dataset dsSearch CODE ON http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3994&lngWId=10 using SQL connection get data from view...
5
3324
by: bob | last post by:
Hi Using 2003 - targeting the compact framework (c#), but would like to do most development using the full.net (manually leaving out stuff not in the compact framework). Q. Trying to find a way of converting a project to have builds for both compact and full. Project properties doesn't seem to help Thanks
4
2238
by: Al | last post by:
I have this scenario: 1. XML file with schema and data is created from SQL Server tables. XML file contains 6 tables, some of them have rows, some of them are empty. 2. XML file is given to the person with Pocket PC. 3. XML file is used to populate DataSet on the Pocket PC. 4. User adds new rows, changes values, deletes some rows. 5. Altered...
1
1587
by: WayneM | last post by:
I have compact framework app that I was trying to test out on a windows form, but I cannot get past the very first step of simply filling a DataGrid from a DataSet. My code is Dim sqlStmt As String = "Select VendorName, StartWeek from InventorySchedule Where FinishDate is Null and StartWeek<'" & Now & "'" Dim cmdDB As New...
3
2830
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one dataset to data in a second dataset, using a common key. I will first describe the problem in words and then I will show my code, which has most of the...
0
7733
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7641
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6338
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5527
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2145
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1241
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.