data access for WinForms

  • Thread starter Thread starter Shimon Sim
  • Start date Start date
S

Shimon Sim

I am looking for architectural solution for data access from WinForms. For
WebForms I am using MS Data Access Application Block with few modifications.
DataReader methods help a lot and this was a big boost for my project.

For WinForms requirements are quiet different. For a example databinding is
must. If you have few windows opened all of them must be in synch. So
Dataset objects comes to mind first but it requires so much coding, with
any change to database I have to change Adapters, then regenerate dataset.
VS has a lot of support for working with datasets but still a lot of hassle.
I would prefer to create data access code separately from UI so in order to
use VS tools for working with Dataset I use Components instead of classes. I
just don't feel that it is considered rapid development.

I just wanted to know if everybody works like this or there is some smarter
solutions out there(please don't offer me to by $1000 application)?
 
Shimon Sim said:
I am looking for architectural solution for data access from WinForms. For
WebForms I am using MS Data Access Application Block with few modifications.
DataReader methods help a lot and this was a big boost for my project.

That dataReader stuff sounds really scarry. They don't lend themeselves to
passing around very well b/c of their dependence one open/available
connections. There are few other dangers that come to mind but this isn't
the crux of your problem and you don't need a lecture on the dangers of
passing DataReaders around ;-)
For WinForms requirements are quiet different. For a example databinding is
must. If you have few windows opened all of them must be in synch.
There's a very easy solution. Host your Datasets/datatables as static
(shared in vb) properties in a module for instance, or just create a class
and make the Dataset property static. You'll be able to access it
everywhere in your app and you'll be using the SAME dataset. All Synch
issues go out the window. Remember that DataTables are safe for
multithreaded read operations, you need to snyc for writes but that only
comes into play if you are multithreading and this is still much safer than
a datareader. Additionally, the same threading issues come up with instance
properties so there's really no difference. All the changes will be
reflected as soon as you make them in all forms. Very easy to do.


So
Dataset objects comes to mind first but it requires so much coding, with
any change to database I have to change Adapters, then regenerate dataset.
VS has a lot of support for working with datasets but still a lot of
hassle.

Not really, as a matter of fact, if you do it like I mentioned, hosting it
as a static member, it's no more work than if you did it in one form alone.
Since you access it everywhere using className.DataSetPropertyName and you
never need to instantiate an instance of it, there's no extra work.
I would prefer to create data access code separately from UI so in order to
use VS tools for working with Dataset I use Components instead of classes. I
just don't feel that it is considered rapid development.

I just wanted to know if everybody works like this or there is some smarter
solutions out there(please don't offer me to by $1000 application)?

Ok, I won't. If you ever decide you might be interested in some first rate
code generators, I know of two that are superb and under $1,000.

Let me know if you have any questions.

Cheers,

Bill--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
 
I suggest that you take a look at how the framework extensions libraries I
have developed manage data binding of a windows form with a single line of
code. The data control is very similar in functionality to that of Microsoft
Access.

Fully documented. Requires .NET framework 1.1 or later.

You will be allowed to use the libraries in any application - private or
commercial, and distribute them as part of your application, royalty-free.

E-mail me for your free copy: (e-mail address removed)
Your acceptance of the license agreement will be required.

Ori
 
Back
Top