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

D

deko

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.
 
G

Guest

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
 
D

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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top