Datasets & Controls

C

Carter

I have 5 controls on a page, each having it's own connection to a database
and different queries per control. Each control is displayed by the user
clicking on a menu. Simple enough.

However, because they are all on one page, each connection and dataset is
created when the first page is loaded, causing that initial opening of the
web site to take a long time. How best to avoid this, and to load the
dataset only when and if the user clicks on a menu, which is in another
control.
 
J

John Saunders

Carter said:
I have 5 controls on a page, each having it's own connection to a database

Are all 5 controls connecting to the same database?

Also, are the connections created inside of the controls? If so, perhaps you
should let the connection be on the page, and pass the connection to the
controls through a property??

Do they operate by creating a DataSet? If so, perhaps it would be better if
the page owned the dataset(s) and passed them to the controls through a
property?
and different queries per control. Each control is displayed by the user
clicking on a menu. Simple enough.

You say "displayed by the user clicking on a menu". Are they invisible
before a menu item is clicked? Do you change their visibility with the
Visible property of the controls? If so, one way to control the DataSet
loading is to not load the DataSet if the control is not Visible.

John Saunders
 
C

Carter

The 5 controls use 2 different databases.

The connections are created inside the controls, mainly because the controls
will possibly be used in other programs, so the connection has to remain
with the control; maybe I should be using custom controls but at this time
I'm not sure I need to.

They all use a dataset except one that uses a datareader.

Making the controls invisible is a good idea, I hadn't thought of that.
Currently the controls are visible according to the panel they are in, when
the user clicks on an item, the corresponding panel becomes visible, but I
agree making the controls invisible first would be more practical, then I
can create the connection and dataset when the control becomes visible.

Another question? How do I pass data from the main page to the control?
The main page has a ClientID; for instance, the user clicks on "address" to
get the address for that particular client. The address control needs to
query the database and create the dataset according to the clientid, fill in
the fields on the control, then display it on the page. I tried to create a
class with public properties but would lose the client id when the page
reloads.

Thanks for your help; as you can tell, I'm pretty much a beginner.
 

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

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,086
Members
48,773
Latest member
Kaybee

Latest Threads

Top