473,769 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Persistence Question

Hi,

Right now I am trying design user data persistence in my winforms app and
have a few questions. Right now the app is designed to save to a local file
however down the road it might be changed to saving to a database. So, I
was thinking about designing a dataset that if I do switch to a database
that it will be easily be converted and dataset could be written to file as
of right now. Is this a good idea or should I just create a custom class?
Also, I have 4 forms which can be open at the same time and can be accessed
in no particular order and do need to persisted. How can I save each?
Should I save to the dataset/class at the time when each form is ready to
persisted and persist the dataset/class each time? Or should I have a custom
class for each form and persist each class until the time when each form
needs to be saved and then add each to the dataset/class?

Thanks for your time
Nov 15 '05 #1
2 1506
"Mike" <sp**@hotmail.c om> wrote in message
news:ep******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

Right now I am trying design user data persistence in my winforms app and
have a few questions. Right now the app is designed to save to a local file however down the road it might be changed to saving to a database. So, I
was thinking about designing a dataset that if I do switch to a database
that it will be easily be converted and dataset could be written to file as of right now. Is this a good idea or should I just create a custom class?
Also, I have 4 forms which can be open at the same time and can be accessed in no particular order and do need to persisted. How can I save each?
Should I save to the dataset/class at the time when each form is ready to
persisted and persist the dataset/class each time? Or should I have a custom class for each form and persist each class until the time when each form
needs to be saved and then add each to the dataset/class?


If you're talking about storing the state of a form, I quite like the idea
of mementos, which are essentially a collection of state/data associated
with a class. You could give each form a GetMemento and SetMemento method
which allows you to save/restore the forms values.

The Memento object itself could just be a DataSet, or a home-grown class
specifically designed to store the state associated with a given form.

If you go for datasets to store form state, then you can easily save/load
the dataset to/from an XML file. If you decide to create custom objects to
store the forms state then you can design them to be serialized using Xml or
some other method.

Personally, I'd probably scoure MSDN for the recommended approach! If I
couldn't find it, then I'd start by using a simple DataSet for storing the
data. If this started to look like it wasn't up to the job, I'd switch to
home-grown objects. I'd also have a SettingsStorage class which would know
how to store the DataSets (or objects). For example, it may know to write
them to XML files, or to a database, or to a binary file, or to another
computer using SOAP etc.

The book about SharpDevelop IDE (search Amazon) talks about using mementos
for storing form state. Also, searching google for the Memento design
pattern may give some interesting resources. Mu first stop may be MSDN
though - as I'm sure this problem has been covered!

HTH!

Tobin

Nov 15 '05 #2
As Tobin said, the Memento Pattern is probably a good option here. Just
save the members you actually need to keep things small. Then persist the
memento using xml or binary serializer (xml text probably easier to get in
and out of database, but have not did much blob work on Sql to know if that
is easy now.) Then if/when you switch to database, you can save the xml
text stream to a single text field in the database. Not sure at this point
if using a typed dataset would buy you anything but overhead - but would
depend on your needs.

--
William Stacey, MVP

"Mike" <sp**@hotmail.c om> wrote in message
news:ep******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

Right now I am trying design user data persistence in my winforms app and
have a few questions. Right now the app is designed to save to a local file however down the road it might be changed to saving to a database. So, I
was thinking about designing a dataset that if I do switch to a database
that it will be easily be converted and dataset could be written to file as of right now. Is this a good idea or should I just create a custom class?
Also, I have 4 forms which can be open at the same time and can be accessed in no particular order and do need to persisted. How can I save each?
Should I save to the dataset/class at the time when each form is ready to
persisted and persist the dataset/class each time? Or should I have a custom class for each form and persist each class until the time when each form
needs to be saved and then add each to the dataset/class?

Thanks for your time

Nov 15 '05 #3

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

Similar topics

6
2073
by: Mark Carter | last post by:
I had a play with XML-RPC the other day, and it seemed really simple to use; which really made an impression on me. But you can't make data persist on the server (not without rolling your own mechanism, at any rate). I'm thinking here about thin clients, where the main process runs on a server. Is there any free solution to this problem? Is SOAP the answer?
6
4189
by: Paolo Losi | last post by:
Hi all, I'm pretty new to the python language so please excuse me if this is FAQ... I'm very glad to be part of the list! :-) I'm looking into a way to implement a generic workflow framework with python. The basic idea is to use python scripts as the way to specify workflow behavior. The framework should not only use scripts as a specification language but is going to leverage on python interpreter for the execution of the scripts. One...
49
2562
by: Paul Rubin | last post by:
I've started a few threads before on object persistence in medium to high end server apps. This one is about low end apps, for example, a simple cgi on a personal web site that might get a dozen hits a day. The idea is you just want to keep a few pieces of data around that the cgi can update. Immediately, typical strategies like using a MySQL database become too big a pain. Any kind of compiled and installed 3rd party module (e.g....
2
1811
by: ryankaskel | last post by:
I don't know if this is the appropriate place to post a Zope question but I figure many here are familiar with it. I'm confused about the role of the ZMI when it comes to development. I want to write a simple script that logs page hits. I wrote it in what was called a Script (Python) resource in the ZMI. When I access the page it gives an error saying that this file cannot import Persistence, etc. This makes sense but where would I put...
1
326
by: Joe | last post by:
I was wondering if there are any recommended persistence frameworks for use in .NET that could be recommended. I am looking for the following requirements: Free/Open Source or very inexpensive. Ease of deployment (no services to install/straight dll) Ability to define entity classes from existing schema and modify later. support for database defined enumerations 1:1,1: many, many:many, bidirectional relationships Transaction support
10
387
by: Simon Harvey | last post by:
Hi everyone, Can anyone tell me if I declare a global variable in my pages code behind, is it persisted if the page does a post back, or do I need to add the object to the session object in order to persist it. Is the session the best mechnism for persisiting this object Thanks everyone
7
2082
by: Steve Mauldin | last post by:
I have a public variable that is declared in a public module. This Variable is stored into a Session variable and used to pass data from page to page. I am seeing on my local development box that once the variable is created and loaded with data and stored into the session variable that on the next aspx page, before the first line of the page load is executed, the public variables data persists. I have not done an assignment from the...
2
2362
by: dkode | last post by:
Hello, I am laying out the architecture for a very large website that will scale to a very large degree. I have a couple of questions before I attempt to go and implement a Broker/Persistence Layer. 1. With a broker layer, does this layer sit at the same level as the Business Layer? So to speak, the presentation layer has knowledge of
5
1500
by: Chris Spencer | last post by:
Before I get too carried away with something that's probably unnecessary, please allow me to throw around some ideas. I've been looking for a method of transparent, scalable, and human-readable object persistence, and I've tried the standard lib's Shelve, Zope's ZODB, Divmod's Axiom, and others. However, while they're all useful, none satisfies all my criteria. So I started writing some toy code of my own: http://paste.plone.org/5227 ...
0
2398
myusernotyours
by: myusernotyours | last post by:
Hi all, Am trying to create a Java Desktop App that uses Java Persistence in Netbeans. The database is MS Access but I tried with Mysql and got the same error. When I run the app( Create the entity manager), I keep getting the following... Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: No Persistence provider for EntityManager named ReceiptingPU: The following providers:...
0
9589
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
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
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.