Saturday, February 6, 2010

Is it better to use multiple asp.net sqldatasource control or programatically populate?

I am using multiple sqldatasource controls to populate several web controls on my page. I was wondering if it would be better to do it so on page_load in the code behind, to programmatically open a connection perform all the queries and then close the connection. Is it better in terms of performance and connections to the database to do it that way?Is it better to use multiple asp.net sqldatasource control or programatically populate?
It's always better to code it yourself. You have no idea what the code in the control is doing. Sometimes you run into a problem because of sloppy coding in a control - with a Microsoft control, you can beat your head on the keyboard for weeks before stumbling on some solution, because you never find out that your code is good, but their control has a bug.





If you write it yourself, it's lighter, and you know what it;s doing.





Opening the connection only when you need it is better for the database. The performance hit is barely measurable on today's computers. (What's a few microseconds?)

No comments:

Post a Comment