Using DataSets

R

Ryan

Quite awile ago I posted to this newsgroup in regards to using Datasets in
my VB 2005 application. About how many Datasets should be used.. a limit to
the number of tables that should be included in a dataset, etc. The
concensus I was given was that one Dataset should be created per logical set
of data, or approximately 1 Dataset per form (usually consisting of 5 or
less tables).

After finishing 2 projects using VB 2005 and DataSets I can emphatically say
it is far easier to design and maintain a single DataSet containing every
table in the database rather than multiple datasets. With multiple
Datasets, when I write new tableadapter queries I either have to save that
query as a stored procedure on the server or I have to rewrite the query for
every dataset that may need it. Overhead with a single dataset also seems
to be negligible because I only populate the datatables only when I need to.
Theres also no logical reason to create a new Dataset per form if what you
need can be attained through the first Dataset, a new instance is created
anyways.

Anyways, just commenting on my experience and maybe someone else can avoid
the trial and error I went through. It seems to me that Microsoft designed
the DataSet object to be an all-encompassing database object. Perhaps my
lack of experience shows so let me disclaim this entire post with the fact
that I went straight from VB 6.0 to .Net 2.0. (missed out on the whole
Visual Studio 2003 .NET thing) :)

Ryan
 
L

Linda Liu [MSFT]

Hi Ryan,

I agree with you that it is more convenient to design and maintain a single
DataSet containing every table in the database rather than multiple
datasets.

DataSet is a type, not an instance. When we are talking about using
DataSet, we are talking about using an instance of the DataSet.
Theres also no logical reason to create a new Dataset per form if what you
need can be attained through the first Dataset, a new instance is created
anyways.

Sorry that I don't understand exactly what you mean in the above sentence.
Generally speaking, when we're going to use DataSet on a form, we create an
instance of the DataSet and then use it.

For lookup data which may be used by multiple forms, we could create a
DataSet containing the lookup tables, then create an instance of the
DataSet and fill it outside any form. When a form wants to use the lookup
data, it needn't create an instance of the lookup DataSet, but uses the
existing instance of the lookup DataSet.

In the end, thank you for sharing your experience to us. I think it will
benefit many readers in the community.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

Cor Ligthert [MVP]

Ryan,

You will love the dataset/datatable approach more and more if you are using
it in different environments as well use it in the way that it fits you the
best.

One thing is that how bad the current very old database SQL base database
approach is, the dataset/datatabe fits it perfectly in every kind of way you
use that.

The way you can use it is endless, while that is even more if you think
about webservices, aspnet, pda etc. etc. However as I started with use it as
it fits you the best, if you are ready you will see that there is a better
approach using the dataset. (Only if you are a good developer, otherwise you
are proud on what you have created).

Just my thought,

Cor
 
R

Ryan

Theres also no logical reason to create a new Dataset per form if what you
need can be attained through the first Dataset, a new instance is created
anyways.

Sorry that I don't understand exactly what you mean in the above sentence.
Generally speaking, when we're going to use DataSet on a form, we create
an
instance of the DataSet and then use it.

I was speaking to the crowd that determined that a new dataset type (not
just an instance of the same dataset) should be created for each form.
There's no reason to do this if you design the Dataset to encompass the
entire database (which I think you should do). Just use the parts of the
dataset you need for the form. If any of those parts (datatables) overlap
with other forms there is no issue because each form has it's own unique
instance of the Dataset. Certainly there should be some built in
consistency checking in the program but this is simple to do by saving
dataset information on a form when that form loses focus (or closes) and
reloading the dataset when the form regains focus.

Thanks for your feedback, Linda. I appreciate your insight.

Ryan
 
J

John

Hi Ryan,

How many tables/columns are in your dataset?

I am curious about this as well. I am starting a new
project with about 110 tables, with an average of
about 18 columns each.

It would be my *guess* that creating an instance of a
strongly-typed dataset containing all tables upon
loading each form would take more memory than
creating an instance of one that only contains the
tables needed for that form. It boils down to I
don't know how much memory each "empty"
datatable uses.

Can you elaborate on your experiences?

Thank you.

John
 
R

Ryan

Hi John,

These particular projects are not nearly as large. They both contain about
20 tables each with about 10 columns (up to 50 columns in some tables less
in others). I would be interested as well if an empty dataset as large as
yours would eat up too much memory, I'm inclined to think it won't. You
could create a Dataset using the default settings in the Dataset wizard
(selecting all your tables) and test using that.

Ryan
 
J

John

Thanks.

I plan on testing it, but I don't have the database/schema on
my machine yet. A colleague is still tweaking it in Embarcadero
before sending me a first draft.

John
 
L

Linda Liu [MSFT]

Hi Ryan,

Thank you for your reply.

Yes, I agree with you that it's not necessary to create a DataSet type for
a form. There's no logical relation ship between them. Designing a DataSet
only depends on how we'd like to use it.

It's always a pleasure to work with you : )


Sincerely,
Linda Liu
Microsoft Online Community Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top