Linking database connections to internal code is bad practice. When you study, I suggest you use web services to interact with the user interface, and not to associate your data interactions with the user interface.
Like UI (Aspx page) → BLL (business logic level) → DAL (data access level)
Also try using the 'using' keyword in the DAL and remove the connections and everything after interacting with the DB
source
share