one or more dataset in one application

Joined
Mar 25, 2009
Messages
23
Programming Experience
Beginner
this is the situation

an application has a main form with many button

a button calls a dialog that is used to add to the database
a button calls a dialog that is used to delete from the database
a button calls a dialog that is used to search and so on

i use many datasets (one per form)

is it the right way , or is it prefered to use one dataset as global and let all the forms deal with it?
 
If you're creating DataSets in forms then yes, creating multiple DataSets in multiple forms is appropriate. It really depends on the specifics of each form as to whether that form requires its own DataSet or it should get data from another form.

As you get more experienced you'll find that it's preferred not to create DataSets in forms at all. The most professional way to build software is with a dedicated data access layer. That data access layer can be constructed in various ways but it handles all the database access and then other components in your application request data from it.
 
As you get more experienced you'll find that it's preferred not to create DataSets in forms at all.

Can you expand on this a little? I'd have advocated that a strongly typed DataSet, and all its associated TableAdapter/DataTable/DataRelation paraphernalia IS a good abstracted data layer for an application.

By contrast, if by "creating datasets in forms " you mean that button click handler code literally contains: Dim ds as New DataSet: ds.Tables.Add(New DataTable): ds.Tables(0).Columns.Add(...)
then yes, I'd agree that it's "bad"

:)
 
I asked for a reference on how to construct the dedicated data access layer

but i want to ask cjard the same question , is it prefered to use one global dataset or use many datasets (one per form)
 
Can you expand on this a little? I'd have advocated that a strongly typed DataSet, and all its associated TableAdapter/DataTable/DataRelation paraphernalia IS a good abstracted data layer for an application.

By contrast, if by "creating datasets in forms " you mean that button click handler code literally contains: Dim ds as New DataSet: ds.Tables.Add(New DataTable): ds.Tables(0).Columns.Add(...)
then yes, I'd agree that it's "bad"

:)
Dragging DataSets and TableAdapters onto forms is simple but violates separation of concerns. Using typed DataSets, DataTables and DataRows as your entity layer and TableAdapters in your DAL is fine, but data access in forms is obviously not when you start talking about serious applications. I know that you know this and were just asking for clarification of my position.
 
Back
Top