locked
Opinion on control database access RRS feed

  • Question

  • User-594738727 posted

    I have created a custom control which directly accesses the database through our database access layer.  It basically accepts two arguments in a method, and using these receives data from the database for display, all through the db access layer.

    A team member has told me that in order to make it fully reusable I should be separately accessing the database from within my page logic, and then just passing the data to the control, for it to show.  However as the control will only be used within this context, I fail to see any problems, and I suppose if their are problems, that particular method doesn't need to be called?

    So what the best practice in this case?

    Friday, December 18, 2009 6:18 AM

Answers

  • User-126244515 posted

    It depends... If you go with your current solution, the custom control is loosely coupled with the page, but tightly coupled/tied to the DAL. Seeing as the control will never stand on it's own, I would go with your team member's suggestion of feeding the data from the page, as it will make it easier to reuse. I know you state that it will not be used elsewhere, but can you really be sure of that, and if so, why create a custom control, if the functionality is really tied to the page? I'm just throwing in more things to consider, and what I would do.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 18, 2009 8:32 AM