MDI & Dataset Strategy Suggestions?

jswota

Well-known member
Joined
Feb 23, 2009
Messages
49
Programming Experience
Beginner
Hi,

I am creating an MDI application where each tab will display various database information. All of the data comes from the same database so i have a single dataset that my tabs get their data from. Each tab uses only a small fraction of the dataset but may also display some of the same data that another tabs displays (ie Project info). Each tab has a report designer/viewer that can display tab sensitive data. I bind my report to the tab's dataset. The desiger displays all of the available tables and fields in the report designer. Many of these tables are empty because the tab does not use them. I am about to write code that will remove unnecessary tables and fields from the designer but before i do i wanted to ask this:

How would you handle this? Would you do the same and use a single dataset that each tab uses or would you have created individual datasets for each tab even though some of the datasets would require the same tables and queries?

Having individual datasets would certainly simplify the report databinding but would also create duplicate data and code.

Any suggestions?

Thanks.
 
When you say "tabs", I assume that you actually mean the child forms. In terms of classes generated by the Data Source wizard, I would never create more than one typed DataSet per database. There's no reason to have more. If your needs aren't catered for by the default schema, change it. You can remove columns from the existing DataTables if they're not used, add queries to TableAdapters to filter data and even add TableAdapters to create DataTables with schemas based on joins. The wizard is just a tool to help. You are still in control. When you create an instance of your typed DataSet, just use the Datatables that are currently relevant.
 
When you say "tabs", I assume that you actually mean the child forms

Yes.

You can remove columns from the existing DataTables if they're not used, add queries to TableAdapters to filter data and even add TableAdapters to create DataTables with schemas based on joins.

This is exactly what i have done. The dataset contains exactly what is necessary. Except, keep in mind, it contains what is necessary for every tab. So the dataset often has more data objects than are required by any individual tab. Now, only the data that applies to the individual tab is loaded so even though the report designer shows irrelevant tables and fields, there is no data in those tables and fields.

I think in my particular case i have certainly found a reason to consider numerous datasets - but is it worth it?

My issue is that i have designed the dataset to satisfy the data requirements of all tabs (child forms.) Each form has an instance of the dataset. It's not necessarily a problem, but the issue is that the dataset has a lot more tables and queries than what is required by any individual form. If i bind the dataset "as is" to my report then all of the unnecessary tables are displayed in the report's field list. I don't want the user to be confused by these additional fields when designing data sensitive reports (i.e. I don't want him to see purchase order information when designing an inventory report.)

To resolve this issue, I have to either...
- "alter" the existing dataset or ...
- create a secondary dataset that contains the relevant data or ...
- Just thought of this one. Remove any unnecessary tables and fields from the report designer after it is loaded. This is probably the best option. I might even be able to assign a tag to each dataset object that defines which tab or tabs it belongs to.

I'm already a couple years into this application so I’m probably not going to completely overhaul my strategy. I am just looking for opinion on the matter to help me plan future projects.

Thanks.
 
Back
Top