473,568 Members | 3,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can an in-memory DataTable be used as a data source for controls?

This is something of a design question.

I have WinForms app that requires persisting a bunch of user settings. The
app maintains a number of "Projects" that contain a variety of parameters,
many of which are Array objects.

Can I store all these things in a DataTable and just serialize/deserialize
the DataTable to XML when the app starts?

What is the best way to persist user settings?

More about the app:

Projects are scheduled to run at user-defined intervals. The app has a
windows service (starts at boot) that maintains a number of TimeSpan objects
(one for each Project) which are independent from the app's UI. When a
project's TimeSpan object counts down to zero, a Project object is
instantiated and it's methods are run.

When the app's GUI is opened, the service's TimeSpan objects need to be
available to client objects in the WinForms app, and displayed in the UI.
This allows a real-time countdown to be displayed.

Would a DataTable be the best way to persist all the various properties that
comprise the Project objects? And then just bind all the UI controls to the
DataTable so the user can adjust them, then serialize the DataTable to an
XML file when the GUI is closed?

Thanks in advance.

Feb 20 '06 #1
2 1245
Deko,
I am not sure that a DataTable is "the best way", but it certainly is an
easy way. Just make sure that you add the table to a new DataSet so that you
can call the WriteXml method to persist it. Same with ReadXml and then
retrieve your DataTable from the DataSet.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"deko" wrote:
This is something of a design question.

I have WinForms app that requires persisting a bunch of user settings. The
app maintains a number of "Projects" that contain a variety of parameters,
many of which are Array objects.

Can I store all these things in a DataTable and just serialize/deserialize
the DataTable to XML when the app starts?

What is the best way to persist user settings?

More about the app:

Projects are scheduled to run at user-defined intervals. The app has a
windows service (starts at boot) that maintains a number of TimeSpan objects
(one for each Project) which are independent from the app's UI. When a
project's TimeSpan object counts down to zero, a Project object is
instantiated and it's methods are run.

When the app's GUI is opened, the service's TimeSpan objects need to be
available to client objects in the WinForms app, and displayed in the UI.
This allows a real-time countdown to be displayed.

Would a DataTable be the best way to persist all the various properties that
comprise the Project objects? And then just bind all the UI controls to the
DataTable so the user can adjust them, then serialize the DataTable to an
XML file when the GUI is closed?

Thanks in advance.

Feb 20 '06 #2
> I am not sure that a DataTable is "the best way", but it certainly is an
easy way. Just make sure that you add the table to a new DataSet so that
you
can call the WriteXml method to persist it. Same with ReadXml and then
retrieve your DataTable from the DataSet.


Thanks for the comments. I think a DataTable is the way to go. Mainly
because my data is relational and also because it offers scalability (if I
ever want to use a database back end). As for "best way" - that's a moving
target, as you suggested.

I've been reading about .NET 2.0's new ApplicationSett ingsBase class. It
sounds great for some things, like UI preferences, but not the kind of
relational data I have to work with. But I'll find some way to use it -
like whether or not there's a systray icon, logging preferences, stuff like
that.

Feb 20 '06 #3

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

Similar topics

3
6749
by: Curious Expatriate | last post by:
Hi- I'm completely stumped. I'm trying to write some code that will parse a file and rewrite it with all URLs replaced by something else. For example: if the file looks like this: <b>click here</b><a href="http://www.cnn.com">click me</a> ... then the output should be this:
1
6260
by: JS Bangs | last post by:
I started using PHP's object-oriented stuff a little while ago, which has mostly been a joy. However, I've noticed that they don't seem to echo as I would like. Eg: $this->field = 255; $this->key = 'id'; echo "$this->key is $this->field"; // prints "id is Array" // Thus I am forced to do this $keyval = $this->field;
5
16146
by: lawrence | last post by:
I've waited 6 weeks for an answer to my other question and still no luck, so let me rephrase the question. I know I can do this: <form method="post" action="$self"> <input type="text" name="filesToDelete"> <input type="text" name="filesToDelete"> <input type="text" name="filesToDelete"> </form>
2
8551
by: Felix | last post by:
Hi, I've a problem: I want to have the result of my Mysql Query in a Table in my php file. Now I've this: <?
1
8699
by: James | last post by:
What is the best way to update a record in a MYSQL DB using a FORM and PHP ? Where ID = $ID ! Any examples or URLS ? Thanks
1
2938
by: Patrick Schlaepfer | last post by:
Why this code is not working on Solaris 2.8 host. Always getting: PHP Fatal error: swfaction() : getURL('http://www.php.net' ^ Line 1: Reason: 'syntax error' in /.../htdocs/ming2.php on line 28
1
2551
by: lawrence | last post by:
What is the PHP equivalent of messaging, as in Java?
3
4907
by: Quinten Carlson | last post by:
Is there a way to conditionally define a function in php? I'm trying to run a php page 10 times using the include statement, but I get an error because my function is already defined. The docs state that a function cannot be undefined and adding "exit" to the included page doesn't free it up either. Any suggestions? B44CCD21
10
3830
by: lawrence | last post by:
I get the impression that most people who are using objects in their PHP projects are mixing them with procedural code. The design, I think, is one where the procedural code is the client code, and the classes are a library of utility code. As such, when I've asked about how to get globals into objects, I've been told that I should pass...
2
27639
by: Phillip Wu | last post by:
Hi, I saw a previous post about sending arrays but did not quite understand the answers. The problem is that I would like to pass an entire array as a hidden input field from one php script to another. I've simplified the code where form1.php calls form2.php when "Go" is hit: form1.php
0
7692
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
7601
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
8117
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
7962
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
6274
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...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2099
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
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
931
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.