accessing the same DB with two calls in two usercontrols...good? bad?

  • Thread starter Thread starter Darrel
  • Start date Start date
D

Darrel

I have a page with a few user controls.

One is the HEADERTAGS (that writes out the tags in the <header> of the page)
and one is MAINCONTENT (that writes out the main body content on the page)

I'm storing the TITLE tag data and the main text data in the same table. How
should I handle getting the above data from this one table via the two
Usercontrols above?

Is it fine to simply have both open a separate connection and grab the
pertinent data? Should only one control grab the data and pass the
information to the other? Does it really matter performance wise on a
smaller site?

-Darrel
 
Technically it's bad, although I wouldn't worry about it on a small
site.

If you're using standard data access against SQL Server, ADO.NET is
probably pooling your connections which further cuts down on the
performance penalty.

If you wanted to optimize this, I'd have the page which contains the
usercontrols do the database hit and set properties in the
usercontrols. That's worked well for me in several production
applications.

- Jon
http://weblogs.asp.net/jgalloway
 
If you wanted to optimize this, I'd have the page which contains the
usercontrols do the database hit and set properties in the
usercontrols. That's worked well for me in several production
applications.

Hmm...good idea. I'm not going to worry about it for this site (it's so
small) but in the future I think perhaps I'll have once control that's in
charge of getting all data and passing that to the appropriate other
controls.

-Darrel
 
Back
Top