Friday, March 9, 2012

Multiple SqlDataSources on a Page

I was wondering, if you have multiple SqlDataSources on a single aspx page, does the framework need to open and close a SEPERATE connection for each SqlDataSource. This would make it much less efficient than coding with the ADO.NET objects and just opn and close the connection once irrespective how many quries that page needs.

Your comments would be appreciated.

Yes, each SqlDataSource is unaware of other data sources on the page. Each SQL Data Source can have it own connection string. Thus, sharing a connection between two might not always be possible if they use different connections.

You are correct, the SqlDataSource isnot meant for performance (but it isn't terrible, either). It is a WYSIWYG control meant for developers that are more comfortable designing their application in the IDE designer rather than by code or for simple pages that don't need the overkill of DataSet, Table Adapters, etc.

|||Many Thanks vcsjones.|||Just another question. Is it possible to tell all sqldatasources to use 1 connection object if the connections are all the same?|||

No, not that I am aware of.

|||Thanks again.

No comments:

Post a Comment