By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,492 Members | 1,289 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,492 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
> 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.