Question Global Dataset versus local dataset

divjoy

Well-known member
Joined
Aug 25, 2013
Messages
159
Programming Experience
1-3
Hi,

I have a good understanding of dataset, datatables and dataadpaters and have used them for a few test programs in vb.net 2010 express and they seem to work OK.

What I would like to ask is where to declare the dataset such that all the Forms in my Windows application can access the same datset if required.

Let em explain I want to download about 6 small tables into a dataset and then bind them to different combobox's on different forms as when the FOrsm are opened.

So I feel I must declare and populate the dataset outside of the forms.

Then with 2 Forms I want to retrieve a larger number of Clients records and Staffs records and have the users update these as they require.

SO the large datatables of Clients and Staff are local to each form and the small datatables are globally available to all forms, does this make sense?

So the question is how should I implement it one dataset or many datasets?

Thanking you for your time..
 
I would suggest that you have one DataSet per form and it loads the data required for that form. If the reference tables are small then it's not much data so retrieving it multiple times will not be an issue. This means that you will only load the large tables where they're needed and they will actually be related to the reference data because it's in the same DataSet.
 
Hi thanks for your reply youve clearly more experience than I, but whats wrong with a global dataset of small tables.
Its the repeated opening of a connection all the time that worries me...
The supporting tables never change so never need updating....
What do you think?
 
I've already said what I think. For one thing, if you have actual foreign keys in your database, which you should, then you'll have DataRelations in your DataSet and you won't be able to create a record in your other tables unless there's a corresponding record in the reference table in the same DataSet. That would require you to actually add the reference tables to each of the individual DataSets you use in the forms. That can be done of course, but you can't relate DataTables in different DataSets.
 
Hi jm,
There will only be one dataset covering the whole application. That's created at the beginning with all the smaller tables. Then only parts of the bigger tables such as Customers and Staff are added as required and updated and deleted when finished with. Referential Integrity is maintained through the use of combo boxes tied to the smaller tables.

This surely has the benefit of less code in each form and not continuously opening connections and loading mutiple tables every time a form is opened!
 
Back
Top