Jamie MacDonald
Jamie MacDonald

Reputation: 13

How do multiple SqlDataSources work?

A bit of background... I have a web page that simply contains 6 drop down lists and a grid. The queries to populate these are very straightforward (maximum of 4 lines) and have been placed into 7 separate SqlDataSources.

The problem I am facing is that the initial pageload is taking far too long and as such was wondering how the SqlDataSource connection actually works.

Does the page open up one transaction for all the sources and then close at the end? Or does it (as I suspect) open and close a separate transaction for each SqlDataSource?

Upvotes: 1

Views: 115

Answers (1)

Joe Letizia
Joe Letizia

Reputation: 55

Even if it is making 7 separate calls to the database, which I suspect it is, it shouldn't take that long considering that you are populating dropdowns with what I can only imagine is a small set of data.

There are several solutions to this problem that might help you.

  1. Set up indexes on the tables that you are querying
  2. Optimize your sql in the datasources (are you doing any funky joins/subquerying?)
  3. Explicitly select the columns you need for the drop downs (Display and data member) and nothing more.

Upvotes: 1

Related Questions