Just learning - Best practice? (using Standard Visual C#. net)

L

LC

In an MDI, winform environment can I assume that there would be
generally only 1 connection object for the project?

Can I assume that for every form that there is a need to access
database info in different ways there will be multiple dataadapters and
then a dataset for each dataadapter? (suppose on 1 form I need to fill
in a datagrid with order information, a listbox with customer
information and a textbox with division name. Would I need a
dataadapter and dataset for each of the order, customer and division
database accesses?

Thanks
 
N

Nicholas Paldino [.NET/C# MVP]

LC,

This all really depends on what you are trying to do. If you have a
need for this, then I would say it's appropriate. However, we don't know
your needs =)

You could try and reduce the overhead of loading the lists for the forms
by having that data loaded in some central location (which anything can
access), and then binding to the results there, instead of fetching them
every time (you have to determine how often the data needs to be refreshed).

For the information you need, I would say you need three separate data
adapters (for the three separate tables).

As for the connection, I would say it is bad to have one connection for
the whole project. The pattern typically is to create the connection when
you need it, use it, then dispose of it. Keeping connections around for a
while can lead to problems if you don't look after them correctly (disposing
of them when done, closing them if you keep them around, things like that).

Hope this helps.
 

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