471,627 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

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 1159
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 ApplicationSettingsBase 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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Curious Expatriate | last post: by
1 post views Thread by JS Bangs | last post: by
5 posts views Thread by lawrence | last post: by
2 posts views Thread by Felix | last post: by
1 post views Thread by James | last post: by
1 post views Thread by Patrick Schlaepfer | last post: by
1 post views Thread by lawrence | last post: by
3 posts views Thread by Quinten Carlson | last post: by
10 posts views Thread by lawrence | last post: by
2 posts views Thread by Phillip Wu | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

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.